@@ -283,7 +283,20 @@ select * from chunk_info;
283
283
_hyper_1_5_chunk | heap | (("time" >= 'Wed Jan 03 16:00:00 2024 PST'::timestamp with time zone) AND ("time" < 'Thu Jan 04 16:00:00 2024 PST'::timestamp with time zone))
284
284
(10 rows)
285
285
286
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
287
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
288
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
289
+ 1 | 6 | 8192 | 0 | 32768 | 16384 | 8192 | 16384 | 1 | 1 | 1
290
+ 3 | 7 | 8192 | 0 | 32768 | 16384 | 8192 | 16384 | 1 | 1 | 1
291
+ (2 rows)
292
+
286
293
call merge_chunks('{_timescaledb_internal._hyper_1_1_chunk, _timescaledb_internal._hyper_1_2_chunk, _timescaledb_internal._hyper_1_3_chunk}');
294
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
295
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
296
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
297
+ 1 | 6 | 16384 | 0 | 65536 | 32768 | 16384 | 32768 | 2 | 2 | 2
298
+ (1 row)
299
+
287
300
select * from chunk_info;
288
301
chunk | tam | checkconstraint
289
302
------------------+------+------------------------------------------------------------------------------------------------------------------------------------------------
@@ -627,14 +640,41 @@ select * from partitions;
627
640
_hyper_1_14_chunk | device | 1431655764 | 9223372036854775807
628
641
(24 rows)
629
642
630
- -- Merge all chunks until only 1 remains
643
+ -- Show which chunks are compressed. Their compression_chunk_size
644
+ -- metadata should be merged.
645
+ select chunk_name from timescaledb_information.chunks
646
+ where is_compressed=true order by chunk_name;
647
+ chunk_name
648
+ ------------------
649
+ _hyper_1_1_chunk
650
+ _hyper_1_2_chunk
651
+ (2 rows)
652
+
653
+ --
654
+ -- Merge all chunks until only 1 remains. Also check that metadata is
655
+ -- merged.
656
+ ---
657
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
658
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
659
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
660
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
661
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
662
+ (2 rows)
663
+
631
664
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
632
665
count | sum | round
633
666
--------+---------+---------------
634
667
518406 | 2854401 | 10373952.7510
635
668
(1 row)
636
669
637
670
call merge_chunks(ARRAY['_timescaledb_internal._hyper_1_1_chunk', '_timescaledb_internal._hyper_1_4_chunk','_timescaledb_internal._hyper_1_5_chunk', '_timescaledb_internal._hyper_1_12_chunk']);
671
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
672
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
673
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
674
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
675
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
676
+ (2 rows)
677
+
638
678
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
639
679
count | sum | round
640
680
--------+---------+---------------
@@ -665,6 +705,13 @@ select * from partitions;
665
705
(18 rows)
666
706
667
707
call merge_chunks(ARRAY['_timescaledb_internal._hyper_1_2_chunk', '_timescaledb_internal._hyper_1_10_chunk','_timescaledb_internal._hyper_1_13_chunk', '_timescaledb_internal._hyper_1_15_chunk']);
708
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
709
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
710
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
711
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
712
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
713
+ (2 rows)
714
+
668
715
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
669
716
count | sum | round
670
717
--------+---------+---------------
@@ -689,6 +736,13 @@ select * from partitions;
689
736
(12 rows)
690
737
691
738
call merge_chunks(ARRAY['_timescaledb_internal._hyper_1_3_chunk', '_timescaledb_internal._hyper_1_11_chunk','_timescaledb_internal._hyper_1_14_chunk', '_timescaledb_internal._hyper_1_16_chunk']);
739
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
740
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
741
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
742
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
743
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
744
+ (2 rows)
745
+
692
746
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
693
747
count | sum | round
694
748
--------+---------+---------------
@@ -707,6 +761,12 @@ select * from partitions;
707
761
(6 rows)
708
762
709
763
call merge_chunks(ARRAY['_timescaledb_internal._hyper_1_3_chunk', '_timescaledb_internal._hyper_1_1_chunk','_timescaledb_internal._hyper_1_2_chunk']);
764
+ select * from _timescaledb_catalog.compression_chunk_size order by chunk_id;
765
+ chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately
766
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
767
+ 1 | 17 | 4857856 | 0 | 8945664 | 32768 | 1359872 | 32768 | 92077 | 96 | 96
768
+ (1 row)
769
+
710
770
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
711
771
count | sum | round
712
772
--------+---------+---------------
0 commit comments