Relyt ONE integrates TimescaleDB, an open-source time-series database extension for PostgreSQL. We use TimescaleDB Apache 2 Edition v2.21.3 to provide powerful time-series capabilities. For a detailed comparison of features between Apache 2 Edition and Community Edition, see the TimescaleDB editions feature comparison.
What is TimescaleDB?
TimescaleDB is a powerful PostgreSQL extension that transforms your database into a high-performance time-series database. It’s designed for handling large volumes of time-stamped data while maintaining full SQL compatibility and leveraging PostgreSQL’s reliability. Key benefits:- Automatic partitioning via hypertables for efficient time-series data storage
- Fast queries with optimized indexing and query planning
- Full SQL support - no need to learn new query languages
- Horizontal scaling capabilities for massive datasets
- Built-in functions for time-series analysis
Prerequisites
Before getting started, ensure you have:- An active Relyt database connection
- TimescaleDB extension enabled on your database
- Basic familiarity with SQL and PostgreSQL
Quick Start
Step 1: Enable TimescaleDB Extension
First, connect to your Relyt database and enable the TimescaleDB extension:timescaledb
listed among your installed extensions.
Step 2: Create Your First Hypertable
A hypertable is TimescaleDB’s core abstraction - it looks like a regular PostgreSQL table but is automatically partitioned by time.The
time
column must be the first argument to create_hypertable()
and should be of type TIMESTAMPTZ
, TIMESTAMP
, or DATE
.Always include a
time
column in your hypertables and ensure it’s properly indexed for optimal performance.Step 3: Insert Time-Series Data
Insert data just like you would with any PostgreSQL table:Step 4: Query Time-Series Data
TimescaleDB provides powerful functions for time-series analysis:Essential TimescaleDB Functions
time_bucket()
The most important function for time-series analysis - groups data into time intervals:first() and last()
Get the first or last value in a time range:Continuous Aggregates
Pre-compute common queries for faster performance:Common Use Cases
IoT Sensor Data
Store and analyze readings from temperature, humidity, and other sensors with automatic time-based partitioning.
Application Metrics
Monitor application performance, response times, and system metrics with efficient time-series queries.
Financial Data
Track stock prices, trading volumes, and market data with millisecond precision.
Log Analytics
Store and analyze application logs, system events, and audit trails over time.
Learn More
This guide covers the basics of using TimescaleDB in Relyt ONE. For comprehensive documentation on advanced features, best practices, and detailed API references, visit the official TimescaleDB documentation:TimescaleDB Official Documentation
Explore advanced features like data retention, compression, continuous aggregates, and performance optimization.
Getting Started: Begin with simple hypertables and basic queries. As your data grows, explore advanced features like continuous aggregates and compression in the official TimescaleDB docs.