Questions tagged [timescaledb]

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension. QUESTIONS MUST BE ABOUT PROGRAMMING in order to be on-topic on Stack Overflow. Specifically, database administration is not on-topic for Stack Overflow.

TimescaleDB

TimescaleDB is an open-source database designed to make SQL scalable for time-series data. It is engineered up from PostgreSQL, providing automatic partitioning across time and space (partitioning key). It speaks full SQL and is correspondingly easy to use like a traditional relational database, yet scales in ways previously reserved for NoSQL databases.

Compared to the trade-offs demanded by these two alternatives (relational vs. NoSQL), TimescaleDB offers the best of both worlds for time-series data:

Features

Easy to Use

  • Full SQL interface for all SQL natively supported by PostgreSQL (including secondary indexes, non-time based aggregates, sub-queries, JOINs, window functions).
  • Connects to any client or tool that speaks PostgreSQL, no changes needed.
  • Time-oriented features, API functions, and optimizations.
  • Robust support for Data retention policies.

Scalable

  • Transparent time/space partitioning for both scaling up (single node) and scaling out (forthcoming).
  • High data write rates (including batched commits, in-memory indexes, transactional support, support for data backfill).
  • Right-sized chunks (two-dimensional data partitions) on single nodes to ensure fast ingest even at large data sizes.
  • Parallelized operations across chunks and servers.

Reliable

  • Engineered up from PostgreSQL, packaged as an extension.
  • Proven foundations benefiting from 20+ years of PostgreSQL research (including streaming replication, backups).
  • Flexible management options (compatible with existing PostgreSQL ecosystem and tooling).

Resources

691 questions
3
votes
3 answers

PostgreSQL: get latest row for each time interval

I have the following table. It is stored as a TimescaleDB hypertable. Data rate is 1 row per second. CREATE TABLE electricity_data ( "time" timestamptz NOT NULL, meter_id integer REFERENCES meters NOT NULL, import_low double precision, …
mhvis
  • 125
  • 2
  • 11
3
votes
1 answer

How to check when a continuous aggregate job was last run on TimescaleDB

I have continuous aggregate views that should refresh automatically. However looks like no data is being written, or it is outdated. This may be misconfiguration, internal failure in TimescaleDB, etc. but in this point I only care to check which…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
3
votes
0 answers

TimescaleDB: Rollup over two different time columns

I'm setting up a TimescaleDB for measurement values. We get measurements that span an interval, so we have a start and end time for measurements. (The interval can be different for different sensors.) We also get updates on measurements and we need…
Bart Kummel
  • 662
  • 12
  • 18
3
votes
1 answer

How can I speed up this SQL query for finding previous entries "on this day"?

I'm trying to speed up this PostgreSQL query to find previous entries "on this day" in past years from a table. I currently have the query below: select * from sample where date_part('month', "timestamp") = date_part('month', now()) and…
jheddings
  • 26,717
  • 8
  • 52
  • 65
3
votes
1 answer

In TimescaleDB how to add retention policy for size instead of time interval?

In TimescaleDB, how to set a standard size in terms of GB/MB for a particular table/hypertable, so that when it reaches a particular size, it begins to delete the old rows in order to accommodate new rows of data. From the documentation, it was…
Ann
  • 137
  • 1
  • 11
3
votes
1 answer

How do I set plan_cache_mode to force_custom_plan in my application?

I have a Spring Boot application with a REST service. I'm using PorstgreSQL as my database with TimescaleDB. I'm trying to set plan_cache_mode to force_custom_plan because I don't want it to switch to generic plan. I'm using Hikari to manage the…
TheStranger
  • 1,387
  • 1
  • 13
  • 35
3
votes
1 answer

How to create insert query with multiple values in python for postgresql

I have datas in df like time location information 2.13 India Good 2.34 USA Good I need to update this to timescale db where time is the unique key, i have used list_db_df=df.values.tolist() Now this turned into a list of values…
3
votes
1 answer

TimescaleDB - get retention policy and chunk_time_interval for a table

Given a hypertable SELECT create_hypertable('conditions', 'time', chunk_time_interval => INTERVAL '1 day'); SELECT add_retention_policy('conditions', INTERVAL '6 months'); in TimescaleDB, how can I retrieve the length of both intervals…
user129186
  • 1,156
  • 2
  • 14
  • 30
3
votes
1 answer

Using time_bucket and joining multiple tables in timescaledb

I have a simple database schema (Timescaledb) with a few tables. Each user has one main sensor with multiple metrics, each metric has its own table with user_id and timestamp. Schema Table 1 | user_id | timestamp | val1 | val... |:---- |:------:|…
3
votes
1 answer

TimescaleDB GROUP BY of time_bucket in view of view not working

PostgreSQL: 13.4 TimescaleDB: 2.4.2 When creating a view that is based on an existing view I cannot GROUP BY a time_bucket field. In the following example you can see three rows each at 20:00:00, those should be one row with the traffic tallied up.…
Splitframe
  • 406
  • 3
  • 16
3
votes
1 answer

Optimising fetching multiple latest values for the last() and GROUP BY in TimescaleDB

I am having a query that fetches the latest price and a price 24h before multiple assets in TimescaleDb. Then my application proceeds to calculate % of the price change on the application side. Because there might not be any trades, the latest price…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
3
votes
1 answer

Timescaledb: get first value before and after range

Given a time series range with values v0-v5 stored at irregular intervals in timescaledb. v0 v1 v2 v3 v4 t0 - t1 - t2 - t3 - t4 - t5 A range starting from >=t2 and to <=t4 is selected resulting in getting v2 and v3. select time from…
kristian mo
  • 1,476
  • 2
  • 11
  • 19
3
votes
1 answer

Why does time_bucket_gapfill consistently throw a PSQLException, at 10th request?

I have a Spring Boot application, with a REST service where I use JdbcTemplate. Then I have a PostgreSQL with TimescaleDB (verson 2.3.0) where the data is stored. In one of my endpoinds, I call the following code to get some timestamps from the…
TheStranger
  • 1,387
  • 1
  • 13
  • 35
3
votes
1 answer

TimescaleDB: performance of a hypertable with append vs. midpoint inserts and indexing

I have some time-series data that I am about to import into TimescaleDB, as (time, item_id, value) tuples in a hypertable. I have created an index: CREATE INDEX ON time_series (item_id, timestamp DESC); Does TimescaleDB have different performance…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
3
votes
1 answer

How do I create a hypertable with TimescaleDB from a table with joint Primary Key?

The question pretty much says it all. I'm trying to create a hypertable with TimescaleDB from a table with joint Primary Key: CREATE TABLE cars ( id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY, time_bought TIMESTAMP NOT NULL, brand…
TheStranger
  • 1,387
  • 1
  • 13
  • 35