Hi @ryanbooz,
This is my point:
I have created an hypertable this way:
create table series.debug (
volt real,
pow real,
temp real,
amb real,
date_time timestamp,
dev integer
);
select create_hypertable('series.debug','date_time',chunk_time_interval => interval '1 day');
alter table series.debug set (
timescaledb.compress
);
select add_compression_policy('series.debug',interval '1 day');
And I have populated with some millions of rows:
volt;pow;temp;amb;date_time;dev
124.96502288285562;5.134368999475538;50.71304726104004;24.611848186196617;2022-01-01 00:00:00+01;1
124.54331128342115;5.104667752443869;48.50125840980479;7.844638924992953;2022-01-01 00:00:13.013+01;1
125.0952434345867;5.520890395941027;58.02202313635234;2.916508707097193;2022-01-01 00:00:26.026+01;1
125.09912625015055;5.1198544702730695;49.020805858636315;9.104279453945713;2022-01-01 00:00:39.039+01;1
124.75021430256223;5.443939469021693;58.11319060884687;10.636756228665945;2022-01-01 00:00:52.052+01;1
124.82799896520162;5.770032349796062;47.73537377933666;21.735795735049827;2022-01-01 00:01:05.065+01;1
124.80921015341288;5.080775711846907;56.2682953674785;9.666804625047737;2022-01-01 00:01:18.078+01;1
124.52633050557026;5.412990094153575;54.55535761321631;21.11484950474803;2022-01-01 00:01:31.091+01;1
124.59405900005154;5.156523779831095;47.3118123483687;4.16914696328751;2022-01-01 00:01:44.104+01;1
....
Afterward:
select compress_chunk(i,if_not_compressed=>true) from show_chunks('series.debug', older_than => interval '1 day') i;
select count(*) from series.debug;
+-----------+
| count |
|-----------|
| 21668142 |
+-----------+
SELECT 1
Time: 3.651s (3 seconds), executed in: 3.639s (3 seconds)
Table size:
select * from hypertable_compression_stats('series.debug');
total_chunks|number_compressed_chunks|before_compression_table_bytes|before_compression_index_bytes|before_compression_toast_bytes|before_compression_total_bytes|after_compression_table_bytes|after_compression_index_bytes|after_compression_toast_bytes|after_compression_total_bytes|node_name|
------------+------------------------+------------------------------+------------------------------+------------------------------+------------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+---------+
31| 31| 1306648576| 196435968| 0| 1503084544| 4513792| 0| 361193472| 365707264| |
SELECT pg_size_pretty(pg_total_relation_size('series.debug')) as size;
size |
----------+
8192 bytes|
So, some Postgresql regular functions are unable to work properly with hypertables and some stored procedures will have to be redone for working with the timescaledb toolkit.
As a consequence, plpgsql functions have to consider differently tables and hypertables. This asimmetry in a Postgresql extension seemed to me a little weird the first time. Thats my fault, clearly, hypertables aren’t tables!
So, implementing timescaledb into some existing DB isn’t so direct as I thought. A little warning and some guide regarding these asymmetries in the documentation wouldn’t be appropriate?
Thank you!