Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar-based chunking PoC #7006

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

erimatnor
Copy link
Contributor

Initial PoC for calendar-based chunking.

A lot of functionality is missing.

Here's some example output:

create table hyper (time timestamptz, device int, temp float);
CREATE TABLE
select create_hypertable('hyper', by_range('time', '1 month'::interval, partition_origin => '2024-01-01'::timestamptz), create_default_indexes => false);
psql:../../tsdb-scripts/calendar-chunking.sql:2: NOTICE:  adding not-null constraint to column "time"
DETAIL:  Dimensions cannot have NULL values.
 create_hypertable 
-------------------
 (1,t)
(1 row)

select * from _timescaledb_catalog.hypertable;
 id | schema_name | table_name | associated_schema_name | associated_table_prefix | num_dimensions | chunk_sizi
ng_func_schema |  chunk_sizing_func_name  | chunk_target_size | compression_state | compressed_hypertable_id | 
status 
----+-------------+------------+------------------------+-------------------------+----------------+-----------
---------------+--------------------------+-------------------+-------------------+--------------------------+-
-------
  1 | public      | hyper      | _timescaledb_internal  | _hyper_1                |              1 | _timescale
db_internal    | calculate_chunk_interval |                 0 |                 0 |                          | 
     0
(1 row)

select * from _timescaledb_catalog.dimension;
 id | hypertable_id | column_name |       column_type        | aligned | num_slices | partitioning_func_schema 
| partitioning_func | interval_origin | interval | interval_length | compress_interval | compress_interval_leng
th | integer_now_func_schema | integer_now_func 
----+---------------+-------------+--------------------------+---------+------------+--------------------------
+-------------------+-----------------+----------+-----------------+-------------------+-----------------------
---+-------------------------+------------------
  1 |             1 | time        | timestamp with time zone | t       |            |                          
|                   | 757378800000000 | 1 mon    |                 |                   |                       
   |                         | 
(1 row)

insert into hyper values ('2024-01-04 13:41', 1, 1.0);
INSERT 0 1
select * from timescaledb_information.chunks;
 hypertable_schema | hypertable_name |     chunk_schema      |    chunk_name    | primary_dimension |  primary_
dimension_type  |      range_start       |       range_end        | range_start_integer | range_end_integer | i
s_compressed | chunk_tablespace |      chunk_creation_time      
-------------------+-----------------+-----------------------+------------------+-------------------+----------
----------------+------------------------+------------------------+---------------------+-------------------+--
-------------+------------------+-------------------------------
 public            | hyper           | _timescaledb_internal | _hyper_1_1_chunk | time              | timestamp
 with time zone | 2024-01-01 00:00:00+01 | 2024-02-01 00:00:00+01 |                     |                   | f
             |                  | 2024-06-05 18:48:14.076832+02
(1 row)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant