@@ -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;
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;
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,40 @@ 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 where is_compressed=true;
646
+ chunk_name
647
+ ------------------
648
+ _hyper_1_1_chunk
649
+ _hyper_1_2_chunk
650
+ (2 rows)
651
+
652
+ --
653
+ -- Merge all chunks until only 1 remains. Also check that metadata is
654
+ -- merged.
655
+ ---
656
+ select * from _timescaledb_catalog.compression_chunk_size;
657
+ 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
658
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
659
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
660
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
661
+ (2 rows)
662
+
631
663
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
632
664
count | sum | round
633
665
--------+---------+---------------
634
666
518406 | 2854401 | 10373952.7510
635
667
(1 row)
636
668
637
669
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']);
670
+ select * from _timescaledb_catalog.compression_chunk_size;
671
+ 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
672
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
673
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
674
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
675
+ (2 rows)
676
+
638
677
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
639
678
count | sum | round
640
679
--------+---------+---------------
@@ -665,6 +704,13 @@ select * from partitions;
665
704
(18 rows)
666
705
667
706
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']);
707
+ select * from _timescaledb_catalog.compression_chunk_size;
708
+ 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
709
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
710
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
711
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
712
+ (2 rows)
713
+
668
714
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
669
715
count | sum | round
670
716
--------+---------+---------------
@@ -689,6 +735,13 @@ select * from partitions;
689
735
(12 rows)
690
736
691
737
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']);
738
+ select * from _timescaledb_catalog.compression_chunk_size;
739
+ 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
740
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
741
+ 1 | 17 | 2441216 | 0 | 4489216 | 16384 | 688128 | 16384 | 46245 | 48 | 48
742
+ 2 | 18 | 2416640 | 0 | 4456448 | 16384 | 671744 | 16384 | 45832 | 48 | 48
743
+ (2 rows)
744
+
692
745
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
693
746
count | sum | round
694
747
--------+---------+---------------
@@ -707,6 +760,12 @@ select * from partitions;
707
760
(6 rows)
708
761
709
762
call merge_chunks(ARRAY['_timescaledb_internal._hyper_1_3_chunk', '_timescaledb_internal._hyper_1_1_chunk','_timescaledb_internal._hyper_1_2_chunk']);
763
+ select * from _timescaledb_catalog.compression_chunk_size;
764
+ 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
765
+ ----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+----------------------------
766
+ 1 | 17 | 4857856 | 0 | 8945664 | 32768 | 1359872 | 32768 | 92077 | 96 | 96
767
+ (1 row)
768
+
710
769
select count(*), sum(device), round(sum(temp)::numeric, 4) from mergeme;
711
770
count | sum | round
712
771
--------+---------+---------------
0 commit comments