DEV Community

Cover image for TimescaleDB Tablespaces
Aniketh Deshpande
Aniketh Deshpande

Posted on

TimescaleDB Tablespaces

Tablespace

  • Tablespace is a storage location where the actual data is stored.

  • The tuples belonging to the same table could be stored in different tablespaces.

  • Tablespaces are mainly used to separately store data of different priority in different kind of disk.

  • Example: Data of active users, or recent active customers can be stored in fast disk types like ssd or flash. Data that is old and unused frequently or archived, can be stored in a less expensive and slower data storage like HDD.


TimescaleDB

  • TimescaleDB is an open source time series database. It is extends PostgreSQL and supports most of the commands of postgres.

  • Docker Image:

docker pull timescale/timescaledb
Enter fullscreen mode Exit fullscreen mode
  • TimescaleDB has a concept of hypertables and chunks. Hypertables are Postgresql tables, that partition the data into chunks.

  • The chunks are created based on primarily the time field.

  • The chunks older than certain date can be moved to a slow disk like HDD and the latest data which would be heavily used can be used in a fast disk like SSD and Flash.

  • The concept of tablespaces helps in here.

  • TSDB code to move chunks:

SELECT move_chunk(
  chunk => '_timescaledb_internal._hyper_1_4_chunk',
  destination_tablespace => 'tablespace_2',
  index_destination_tablespace => 'tablespace_3',
  reorder_index => 'conditions_device_id_time_idx',
  verbose => TRUE
);
Enter fullscreen mode Exit fullscreen mode

For detailed information, use the following link: https://legacy-docs.timescale.com/v1.7/api#move_chunk


AWS Volumes

  • If the TSDB instance is hosted in a kubernetes cluster in AWS, the TSDB pod would be provided with an AWS Volume for persistent storage.

  • AWS supports the following volume classes. Based on speed and cost requirements, we can select the appropriate volumes for TSDB tablespaces.

  • AWS volume types: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html


Thank you for reading the blog :)
Aniketh Deshpande

Top comments (1)

Collapse
 
rudu1 profile image
Rudram

Your account is like a bible for data engineers