Welcome to the forum Jason!
You can absolutely do this with space partitioning:
a=# select add_dimension('historian.Ms', 'tag_id', chunk_time_interval=>1);
add_dimension
---------------------------
(2,historian,ms,tag_id,t)
(1 row)
a=# insert into historian.ms values(now(), 1, 1);
INSERT 0 1
a=# insert into historian.ms values(now(), 1, 2);
INSERT 0 1
a=# insert into historian.ms values(now() - interval '1 day', 1, 1);
INSERT 0 1
a=# insert into historian.ms values(now(), 2, 1);
INSERT 0 1
a=# insert into historian.ms values(now(), 5, 1);
INSERT 0 1
a=# \d+ historian.ms
Table "historian.ms"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-----------+--------------------------+-----------+----------+---------+---------+-------------+--------------+-------------
timestamp | timestamp with time zone | | not null | | plain | | |
tag_id | smallint | | not null | | plain | | |
value | double precision | | | | plain | | |
Indexes:
"ms_tag_id_idx" btree (tag_id)
"ms_timestamp_idx" btree ("timestamp" DESC)
Triggers:
ts_insert_blocker BEFORE INSERT ON historian.ms FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker()
Child tables: _timescaledb_internal._hyper_1_1_chunk,
_timescaledb_internal._hyper_1_2_chunk,
_timescaledb_internal._hyper_1_3_chunk
_timescaledb_internal._hyper_1_4_chunk
Access method: heap
Now should you do this - that’s a harder question. How many chunks are you likely to have if you enable space partitioning (worst case it would be total tags * total time chunks
)?
We recommend extreme caution when choosing to use space partitioning.
-James