What is space partitioning and dimensions in TimesclaleDB
Asked Answered
M

1

6

I am new to the Timescale database. I was learning about chunks and how to create chunks based on time.
But there is another time/space chunking which is confusing me a lot.

  1. What is a "dimension" in a timescale DB?
  2. What is "space" chunking and how does it work?
Mccubbin answered 2/5, 2020 at 2:10 Comment(0)
E
18

A dimension in TimescaleDB is associated with a column. Each hypertable requires to define at least a time dimension, which is a time column for the time series. Then a hypertable is divided into chunks, where each chunk contains data for a time interval of the time dimension. As result all new data usually arrives into the latets chunk, while other chunks contain older data.

Then, it is possible to define space dimensions on other columns, for example device column or/and location column. No interval is defined for space dimensions, instead a number of partitions is defined. So for the same time interval, several chunks will be created, which is equivalent to the number of partitions. Data are distributed by a hashing function on the values of the space dimension. For example, if 3 partitions are defined for a space dimension on device column and 12 different device values were present in the data, each space chunk will contain 4 different values with a hash function uniformly distributing the values.

Space dimensions are specifically useful for parallel I/O, when data are stored on several disks. Another scenario is multinode, i.e., distributed version of hypertable (beta feature, which coming to release in 2.0).

There are some complex usage cases when space partitioning will be also helpful.

You can read more in add_dimension docs, cloud KB about space partitioning

A note in the doc:

Supporting more than one additional dimension is currently experimental.

Eddins answered 2/5, 2020 at 13:23 Comment(6)
Thank you very much for describing in such an easy way. It helps me a lot to clear my doubts. Again, Thanks to you.Mccubbin
I am glad that it helps. I hope it will help others too. I will try to update links when I see new related information.Eddins
How many chunks will get created if I have time-based chunking for 1-day interval and space-based chunking (column1 with partition 3 and column2 with partition 5 ). Now if time and column1 value will remain same and column2 value will vary.Mccubbin
According to the doc about add_dimension: Supporting more than one additional dimension is currently experimental.Eddins
Since number of partitions is specified for each dimension, then I believe the total number of partitions will be a product of the numbers.Eddins
Thank you very much for your response.Mccubbin

© 2022 - 2024 — McMap. All rights reserved.