From 36f796f0e43b8af9ecb214574862361a90bf30a9 Mon Sep 17 00:00:00 2001 From: Keyur Panchal Date: Mon, 25 Nov 2024 17:37:53 -0700 Subject: [PATCH] Fix broken tests --- tsl/test/expected/compression.out | 10 +- tsl/test/expected/compression_bgw.out | 12 +- tsl/test/expected/compression_ddl.out | 236 ++++++------------ tsl/test/expected/compression_insert.out | 60 ++--- .../expected/compression_qualpushdown.out | 4 +- .../compression_sequence_num_removal.out | 38 +-- .../expected/compression_update_delete-14.out | 164 ++++++------ .../expected/compression_update_delete-15.out | 164 ++++++------ .../expected/compression_update_delete-16.out | 164 ++++++------ .../expected/compression_update_delete-17.out | 164 ++++++------ tsl/test/expected/hypercore.out | 4 +- tsl/test/expected/hypercore_vacuum.out | 9 +- .../expected/recompress_chunk_segmentwise.out | 3 + tsl/test/expected/telemetry_stats.out | 4 +- tsl/test/expected/vector_agg_default.out | 14 +- tsl/test/sql/recompress_chunk_segmentwise.sql | 2 + 16 files changed, 442 insertions(+), 610 deletions(-) diff --git a/tsl/test/expected/compression.out b/tsl/test/expected/compression.out index fc5e0ec56db..6dd2bb7fb9f 100644 --- a/tsl/test/expected/compression.out +++ b/tsl/test/expected/compression.out @@ -2794,12 +2794,12 @@ COPY compressed_table (time,a,b,c) FROM stdin; SELECT compress_chunk(i, if_not_compressed => true) FROM show_chunks('compressed_table') i; compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_49_108_chunk + _timescaledb_internal._hyper_49_107_chunk (1 row) \set ON_ERROR_STOP 0 COPY compressed_table (time,a,b,c) FROM stdin; -ERROR: duplicate key value violates unique constraint "_hyper_49_108_chunk_compressed_table_index" +ERROR: duplicate key value violates unique constraint "_hyper_49_107_chunk_compressed_table_index" \set ON_ERROR_STOP 1 COPY compressed_table (time,a,b,c) FROM stdin; SELECT * FROM compressed_table; @@ -2813,7 +2813,7 @@ SELECT * FROM compressed_table; SELECT compress_chunk(i, if_not_compressed => true) FROM show_chunks('compressed_table') i; compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_49_108_chunk + _timescaledb_internal._hyper_49_107_chunk (1 row) -- Check DML decompression limit @@ -2837,7 +2837,7 @@ NOTICE: default order by for hypertable "hyper_84" is set to ""time" DESC" SELECT compress_chunk(ch) FROM show_chunks('hyper_84') ch; compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_51_110_chunk + _timescaledb_internal._hyper_51_109_chunk (1 row) -- indexscan for decompression: UPDATE @@ -2845,7 +2845,7 @@ UPDATE hyper_84 SET temp = 100 where device = 1; SELECT compress_chunk(ch) FROM show_chunks('hyper_84') ch; compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_51_110_chunk + _timescaledb_internal._hyper_51_109_chunk (1 row) -- indexscan for decompression: DELETE diff --git a/tsl/test/expected/compression_bgw.out b/tsl/test/expected/compression_bgw.out index fddf7b28022..a5694442f78 100644 --- a/tsl/test/expected/compression_bgw.out +++ b/tsl/test/expected/compression_bgw.out @@ -175,8 +175,8 @@ WHERE compression_status LIKE 'Compressed' ORDER BY chunk_name; chunk_name | before_compression_total_bytes | after_compression_total_bytes ------------------+--------------------------------+------------------------------- - _hyper_3_5_chunk | 24576 | 24576 - _hyper_3_6_chunk | 24576 | 24576 + _hyper_3_5_chunk | 24576 | 40960 + _hyper_3_6_chunk | 24576 | 40960 (2 rows) --integer tests @@ -215,8 +215,8 @@ WHERE compression_status LIKE 'Compressed' ORDER BY chunk_name; chunk_name | before_compression_total_bytes | after_compression_total_bytes -------------------+--------------------------------+------------------------------- - _hyper_5_12_chunk | 24576 | 24576 - _hyper_5_13_chunk | 24576 | 24576 + _hyper_5_12_chunk | 24576 | 40960 + _hyper_5_13_chunk | 24576 | 40960 (2 rows) --bigint test @@ -255,8 +255,8 @@ WHERE compression_status LIKE 'Compressed' ORDER BY chunk_name; chunk_name | before_compression_total_bytes | after_compression_total_bytes -------------------+--------------------------------+------------------------------- - _hyper_7_19_chunk | 24576 | 24576 - _hyper_7_20_chunk | 24576 | 24576 + _hyper_7_19_chunk | 24576 | 40960 + _hyper_7_20_chunk | 24576 | 40960 (2 rows) --TEST 8 diff --git a/tsl/test/expected/compression_ddl.out b/tsl/test/expected/compression_ddl.out index edb7008c317..03846e3d0c1 100644 --- a/tsl/test/expected/compression_ddl.out +++ b/tsl/test/expected/compression_ddl.out @@ -1899,49 +1899,37 @@ SELECT compress_chunk(show_chunks('test_partials')); VACUUM ANALYZE test_partials; -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_33_120_chunk - -> Sort - Sort Key: compress_hyper_34_123_chunk._ts_meta_min_1, compress_hyper_34_123_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_123_chunk + -> Index Scan Backward using compress_hyper_34_123_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_123_chunk -> Custom Scan (DecompressChunk) on _hyper_33_121_chunk - -> Sort - Sort Key: compress_hyper_34_124_chunk._ts_meta_min_1, compress_hyper_34_124_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_124_chunk + -> Index Scan Backward using compress_hyper_34_124_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_124_chunk -> Custom Scan (DecompressChunk) on _hyper_33_122_chunk - -> Sort - Sort Key: compress_hyper_34_125_chunk._ts_meta_min_1, compress_hyper_34_125_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_125_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_34_125_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_125_chunk +(8 rows) -- test P, F, F INSERT INTO test_partials VALUES ('2020-01-01 00:03', 1, 2); EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_33_120_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_120_chunk - -> Sort - Sort Key: compress_hyper_34_123_chunk._ts_meta_min_1, compress_hyper_34_123_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_123_chunk + -> Index Scan Backward using compress_hyper_34_123_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_123_chunk -> Sort Sort Key: _hyper_33_120_chunk."time" -> Seq Scan on _hyper_33_120_chunk -> Custom Scan (DecompressChunk) on _hyper_33_121_chunk - -> Sort - Sort Key: compress_hyper_34_124_chunk._ts_meta_min_1, compress_hyper_34_124_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_124_chunk + -> Index Scan Backward using compress_hyper_34_124_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_124_chunk -> Custom Scan (DecompressChunk) on _hyper_33_122_chunk - -> Sort - Sort Key: compress_hyper_34_125_chunk._ts_meta_min_1, compress_hyper_34_125_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_125_chunk -(19 rows) + -> Index Scan Backward using compress_hyper_34_125_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_125_chunk +(13 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -1961,33 +1949,27 @@ SELECT * FROM test_partials ORDER BY time; -- P, P, F INSERT INTO test_partials VALUES ('2021-01-01 00:03', 1, 2); EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_33_120_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_120_chunk - -> Sort - Sort Key: compress_hyper_34_123_chunk._ts_meta_min_1, compress_hyper_34_123_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_123_chunk + -> Index Scan Backward using compress_hyper_34_123_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_123_chunk -> Sort Sort Key: _hyper_33_120_chunk."time" -> Seq Scan on _hyper_33_120_chunk -> Merge Append Sort Key: _hyper_33_121_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_121_chunk - -> Sort - Sort Key: compress_hyper_34_124_chunk._ts_meta_min_1, compress_hyper_34_124_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_124_chunk + -> Index Scan Backward using compress_hyper_34_124_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_124_chunk -> Sort Sort Key: _hyper_33_121_chunk."time" -> Seq Scan on _hyper_33_121_chunk -> Custom Scan (DecompressChunk) on _hyper_33_122_chunk - -> Sort - Sort Key: compress_hyper_34_125_chunk._ts_meta_min_1, compress_hyper_34_125_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_125_chunk -(24 rows) + -> Index Scan Backward using compress_hyper_34_125_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_125_chunk +(18 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2009,39 +1991,33 @@ SELECT * FROM test_partials ORDER BY time; INSERT INTO test_partials VALUES ('2022-01-01 00:03', 1, 2); INSERT INTO test_partials VALUES ('2023-01-01 00:03', 1, 2); EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_33_120_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_120_chunk - -> Sort - Sort Key: compress_hyper_34_123_chunk._ts_meta_min_1, compress_hyper_34_123_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_123_chunk + -> Index Scan Backward using compress_hyper_34_123_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_123_chunk -> Sort Sort Key: _hyper_33_120_chunk."time" -> Seq Scan on _hyper_33_120_chunk -> Merge Append Sort Key: _hyper_33_121_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_121_chunk - -> Sort - Sort Key: compress_hyper_34_124_chunk._ts_meta_min_1, compress_hyper_34_124_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_124_chunk + -> Index Scan Backward using compress_hyper_34_124_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_124_chunk -> Sort Sort Key: _hyper_33_121_chunk."time" -> Seq Scan on _hyper_33_121_chunk -> Merge Append Sort Key: _hyper_33_122_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_122_chunk - -> Sort - Sort Key: compress_hyper_34_125_chunk._ts_meta_min_1, compress_hyper_34_125_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_125_chunk + -> Index Scan Backward using compress_hyper_34_125_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_125_chunk -> Sort Sort Key: _hyper_33_122_chunk."time" -> Seq Scan on _hyper_33_122_chunk -> Index Scan Backward using _hyper_33_126_chunk_test_partials_time_idx on _hyper_33_126_chunk -(30 rows) +(24 rows) -- F, F, P, U -- recompress all chunks @@ -2060,29 +2036,23 @@ END $$; INSERT INTO test_partials VALUES ('2022-01-01 00:02', 1, 2); EXPLAIN (COSTS OFF) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_33_120_chunk - -> Sort - Sort Key: compress_hyper_34_127_chunk._ts_meta_min_1, compress_hyper_34_127_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_127_chunk + -> Index Scan Backward using compress_hyper_34_127_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_127_chunk -> Custom Scan (DecompressChunk) on _hyper_33_121_chunk - -> Sort - Sort Key: compress_hyper_34_128_chunk._ts_meta_min_1, compress_hyper_34_128_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_128_chunk + -> Index Scan Backward using compress_hyper_34_128_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_128_chunk -> Merge Append Sort Key: _hyper_33_122_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_122_chunk - -> Sort - Sort Key: compress_hyper_34_129_chunk._ts_meta_min_1, compress_hyper_34_129_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_129_chunk + -> Index Scan Backward using compress_hyper_34_129_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_129_chunk -> Sort Sort Key: _hyper_33_122_chunk."time" -> Seq Scan on _hyper_33_122_chunk -> Index Scan Backward using _hyper_33_126_chunk_test_partials_time_idx on _hyper_33_126_chunk -(20 rows) +(14 rows) -- F, F, P, F, F INSERT INTO test_partials VALUES ('2024-01-01 00:02', 1, 2); @@ -2094,36 +2064,26 @@ SELECT compress_chunk(c) FROM show_chunks('test_partials', newer_than => '2022-0 (2 rows) EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_33_120_chunk - -> Sort - Sort Key: compress_hyper_34_127_chunk._ts_meta_min_1, compress_hyper_34_127_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_127_chunk + -> Index Scan Backward using compress_hyper_34_127_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_127_chunk -> Custom Scan (DecompressChunk) on _hyper_33_121_chunk - -> Sort - Sort Key: compress_hyper_34_128_chunk._ts_meta_min_1, compress_hyper_34_128_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_128_chunk + -> Index Scan Backward using compress_hyper_34_128_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_128_chunk -> Merge Append Sort Key: _hyper_33_122_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_33_122_chunk - -> Sort - Sort Key: compress_hyper_34_129_chunk._ts_meta_min_1, compress_hyper_34_129_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_129_chunk + -> Index Scan Backward using compress_hyper_34_129_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_129_chunk -> Sort Sort Key: _hyper_33_122_chunk."time" -> Seq Scan on _hyper_33_122_chunk -> Custom Scan (DecompressChunk) on _hyper_33_126_chunk - -> Sort - Sort Key: compress_hyper_34_131_chunk._ts_meta_min_1, compress_hyper_34_131_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_131_chunk + -> Index Scan Backward using compress_hyper_34_131_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_131_chunk -> Custom Scan (DecompressChunk) on _hyper_33_130_chunk - -> Sort - Sort Key: compress_hyper_34_132_chunk._ts_meta_min_1, compress_hyper_34_132_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_34_132_chunk -(27 rows) + -> Index Scan Backward using compress_hyper_34_132_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_34_132_chunk +(17 rows) -- verify result correctness SELECT * FROM test_partials ORDER BY time; @@ -2191,24 +2151,20 @@ SELECT add_dimension('space_part', 'a', number_partitions => 5); -- plan is still the same EXPLAIN (COSTS OFF) SELECT * FROM space_part ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on space_part Order: space_part."time" -> Merge Append Sort Key: _hyper_35_133_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_133_chunk - -> Sort - Sort Key: compress_hyper_36_135_chunk._ts_meta_min_1, compress_hyper_36_135_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_135_chunk + -> Index Scan Backward using compress_hyper_36_135_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_135_chunk -> Sort Sort Key: _hyper_35_133_chunk."time" -> Seq Scan on _hyper_35_133_chunk -> Custom Scan (DecompressChunk) on _hyper_35_134_chunk - -> Sort - Sort Key: compress_hyper_36_136_chunk._ts_meta_min_1, compress_hyper_36_136_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_136_chunk -(15 rows) + -> Index Scan Backward using compress_hyper_36_136_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_136_chunk +(11 rows) -- now add more chunks that do adhere to the new space partitioning -- chunks 3,4 @@ -2219,28 +2175,24 @@ INSERT INTO space_part VALUES ('2022-01-01 00:03', 2, 1, 1); -- plan still ok EXPLAIN (COSTS OFF) SELECT * FROM space_part ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on space_part Order: space_part."time" -> Merge Append Sort Key: _hyper_35_133_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_133_chunk - -> Sort - Sort Key: compress_hyper_36_135_chunk._ts_meta_min_1, compress_hyper_36_135_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_135_chunk + -> Index Scan Backward using compress_hyper_36_135_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_135_chunk -> Sort Sort Key: _hyper_35_133_chunk."time" -> Seq Scan on _hyper_35_133_chunk -> Custom Scan (DecompressChunk) on _hyper_35_134_chunk - -> Sort - Sort Key: compress_hyper_36_136_chunk._ts_meta_min_1, compress_hyper_36_136_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_136_chunk + -> Index Scan Backward using compress_hyper_36_136_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_136_chunk -> Merge Append Sort Key: _hyper_35_137_chunk."time" -> Index Scan Backward using _hyper_35_137_chunk_space_part_time_idx on _hyper_35_137_chunk -> Index Scan Backward using _hyper_35_138_chunk_space_part_time_idx on _hyper_35_138_chunk -(19 rows) +(15 rows) -- compress them SELECT compress_chunk(c, if_not_compressed=>true) FROM show_chunks('space_part') c; @@ -2255,95 +2207,71 @@ NOTICE: chunk "_hyper_35_134_chunk" is already compressed -- plan still ok EXPLAIN (COSTS OFF) SELECT * FROM space_part ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on space_part Order: space_part."time" -> Custom Scan (DecompressChunk) on _hyper_35_133_chunk - -> Sort - Sort Key: compress_hyper_36_139_chunk._ts_meta_min_1, compress_hyper_36_139_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_139_chunk + -> Index Scan Backward using compress_hyper_36_135_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_135_chunk -> Custom Scan (DecompressChunk) on _hyper_35_134_chunk - -> Sort - Sort Key: compress_hyper_36_136_chunk._ts_meta_min_1, compress_hyper_36_136_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_136_chunk + -> Index Scan Backward using compress_hyper_36_136_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_136_chunk -> Merge Append Sort Key: _hyper_35_137_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_137_chunk - -> Sort - Sort Key: compress_hyper_36_140_chunk._ts_meta_min_1, compress_hyper_36_140_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_140_chunk + -> Index Scan Backward using compress_hyper_36_139_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_139_chunk -> Custom Scan (DecompressChunk) on _hyper_35_138_chunk - -> Sort - Sort Key: compress_hyper_36_141_chunk._ts_meta_min_1, compress_hyper_36_141_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_141_chunk -(20 rows) + -> Index Scan Backward using compress_hyper_36_140_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_140_chunk +(12 rows) -- make second one of them partial insert into space_part values ('2022-01-01 00:02', 2, 1, 1), ('2022-01-01 00:02', 2, 1, 1); EXPLAIN (COSTS OFF) SELECT * FROM space_part ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on space_part Order: space_part."time" -> Custom Scan (DecompressChunk) on _hyper_35_133_chunk - -> Sort - Sort Key: compress_hyper_36_139_chunk._ts_meta_min_1, compress_hyper_36_139_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_139_chunk + -> Index Scan Backward using compress_hyper_36_135_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_135_chunk -> Custom Scan (DecompressChunk) on _hyper_35_134_chunk - -> Sort - Sort Key: compress_hyper_36_136_chunk._ts_meta_min_1, compress_hyper_36_136_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_136_chunk + -> Index Scan Backward using compress_hyper_36_136_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_136_chunk -> Merge Append Sort Key: _hyper_35_137_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_137_chunk - -> Sort - Sort Key: compress_hyper_36_140_chunk._ts_meta_min_1, compress_hyper_36_140_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_140_chunk + -> Index Scan Backward using compress_hyper_36_139_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_139_chunk -> Custom Scan (DecompressChunk) on _hyper_35_138_chunk - -> Sort - Sort Key: compress_hyper_36_141_chunk._ts_meta_min_1, compress_hyper_36_141_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_141_chunk + -> Index Scan Backward using compress_hyper_36_140_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_140_chunk -> Sort Sort Key: _hyper_35_138_chunk."time" -> Seq Scan on _hyper_35_138_chunk -(23 rows) +(15 rows) -- make other one partial too INSERT INTO space_part VALUES ('2022-01-01 00:02', 1, 1, 1); EXPLAIN (COSTS OFF) SELECT * FROM space_part ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ Custom Scan (ChunkAppend) on space_part Order: space_part."time" -> Custom Scan (DecompressChunk) on _hyper_35_133_chunk - -> Sort - Sort Key: compress_hyper_36_139_chunk._ts_meta_min_1, compress_hyper_36_139_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_139_chunk + -> Index Scan Backward using compress_hyper_36_135_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_135_chunk -> Custom Scan (DecompressChunk) on _hyper_35_134_chunk - -> Sort - Sort Key: compress_hyper_36_136_chunk._ts_meta_min_1, compress_hyper_36_136_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_136_chunk + -> Index Scan Backward using compress_hyper_36_136_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_136_chunk -> Merge Append Sort Key: _hyper_35_137_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_137_chunk - -> Sort - Sort Key: compress_hyper_36_140_chunk._ts_meta_min_1, compress_hyper_36_140_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_140_chunk + -> Index Scan Backward using compress_hyper_36_139_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_139_chunk -> Sort Sort Key: _hyper_35_137_chunk."time" -> Seq Scan on _hyper_35_137_chunk -> Custom Scan (DecompressChunk) on _hyper_35_138_chunk - -> Sort - Sort Key: compress_hyper_36_141_chunk._ts_meta_min_1, compress_hyper_36_141_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_141_chunk + -> Index Scan Backward using compress_hyper_36_140_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_140_chunk -> Sort Sort Key: _hyper_35_138_chunk."time" -> Seq Scan on _hyper_35_138_chunk -(26 rows) +(18 rows) -- test creation of unique expression index does not interfere with enabling compression -- github issue 6205 @@ -2372,14 +2300,14 @@ values ('meter1', 1, 2.3, '2022-01-01'::timestamptz, '2022-01-01'::timestamptz), select compress_chunk(show_chunks('mytab')); compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_37_142_chunk + _timescaledb_internal._hyper_37_141_chunk (1 row) REINDEX TABLE mytab; -- should update index select decompress_chunk(show_chunks('mytab')); decompress_chunk ------------------------------------------- - _timescaledb_internal._hyper_37_142_chunk + _timescaledb_internal._hyper_37_141_chunk (1 row) \set EXPLAIN 'EXPLAIN (costs off,timing off,summary off)' @@ -2390,7 +2318,7 @@ set enable_indexscan = on; :EXPLAIN_ANALYZE select * from mytab where lower(col1::text) = 'meter1'; QUERY PLAN -------------------------------------------------------------------------------------------------- - Index Scan using _hyper_37_142_chunk_myidx_unique on _hyper_37_142_chunk (actual rows=3 loops=1) + Index Scan using _hyper_37_141_chunk_myidx_unique on _hyper_37_141_chunk (actual rows=3 loops=1) Index Cond: (lower((col1)::text) = 'meter1'::text) (2 rows) @@ -2408,19 +2336,19 @@ WHERE (value > 2.4 AND value < 3); select compress_chunk(show_chunks('mytab')); compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_37_142_chunk + _timescaledb_internal._hyper_37_141_chunk (1 row) select decompress_chunk(show_chunks('mytab')); decompress_chunk ------------------------------------------- - _timescaledb_internal._hyper_37_142_chunk + _timescaledb_internal._hyper_37_141_chunk (1 row) :EXPLAIN_ANALYZE SELECT * FROM mytab WHERE value BETWEEN 2.4 AND 2.8; QUERY PLAN --------------------------------------------------------------------------------------- - Seq Scan on _hyper_37_142_chunk (actual rows=1 loops=1) + Seq Scan on _hyper_37_141_chunk (actual rows=1 loops=1) Filter: ((value >= '2.4'::double precision) AND (value <= '2.8'::double precision)) Rows Removed by Filter: 2 (3 rows) @@ -2471,28 +2399,28 @@ NOTICE: default order by for hypertable "hyper_unique_deferred" is set to ""tim select compress_chunk(show_chunks('hyper_unique_deferred')); -- also worked fine before 2.11.0 compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_40_146_chunk + _timescaledb_internal._hyper_40_145_chunk (1 row) select decompress_chunk(show_chunks('hyper_unique_deferred')); decompress_chunk ------------------------------------------- - _timescaledb_internal._hyper_40_146_chunk + _timescaledb_internal._hyper_40_145_chunk (1 row) \set ON_ERROR_STOP 0 begin; insert INTO hyper_unique_deferred values (1257987700000000000, 'dev1', 1); abort; -ERROR: new row for relation "_hyper_40_146_chunk" violates check constraint "hyper_unique_deferred_sensor_1_check" +ERROR: new row for relation "_hyper_40_145_chunk" violates check constraint "hyper_unique_deferred_sensor_1_check" \set ON_ERROR_STOP 1 select compress_chunk(show_chunks('hyper_unique_deferred')); compress_chunk ------------------------------------------- - _timescaledb_internal._hyper_40_146_chunk + _timescaledb_internal._hyper_40_145_chunk (1 row) \set ON_ERROR_STOP 0 begin; insert INTO hyper_unique_deferred values (1257987700000000000, 'dev1', 1); abort; -ERROR: duplicate key value violates unique constraint "146_2_hyper_unique_deferred_time_key" +ERROR: duplicate key value violates unique constraint "145_2_hyper_unique_deferred_time_key" \set ON_ERROR_STOP 1 -- tests chunks being compressed using different segmentby settings -- github issue #7102 @@ -2522,7 +2450,7 @@ FROM timescaledb_information.chunks WHERE hypertable_name = 'compression_drop' AND NOT is_compressed; CHUNK_NAME ------------------------------------------- - _timescaledb_internal._hyper_42_151_chunk + _timescaledb_internal._hyper_42_150_chunk (1 row) -- try dropping column v0, should fail @@ -2552,7 +2480,7 @@ ALTER TABLE test2 SET ( ); \set ON_ERROR_STOP 0 INSERT INTO test2(ts,b,t) VALUES ('2024-11-18 18:04:51',99,'magic'); -ERROR: null value in column "i" of relation "_hyper_44_180_chunk" violates not-null constraint +ERROR: null value in column "i" of relation "_hyper_44_179_chunk" violates not-null constraint \set ON_ERROR_STOP 1 ALTER TABLE test2 ALTER COLUMN i DROP NOT NULL; INSERT INTO test2(ts,b,t) VALUES ('2024-11-18 18:04:51',99,'magic'); diff --git a/tsl/test/expected/compression_insert.out b/tsl/test/expected/compression_insert.out index 12da960379e..97e488f93d1 100644 --- a/tsl/test/expected/compression_insert.out +++ b/tsl/test/expected/compression_insert.out @@ -790,13 +790,11 @@ SELECT compress_chunk(format('%I.%I',chunk_schema,chunk_name), true) FROM timesc -- should be ordered append :PREFIX SELECT * FROM test_ordering ORDER BY 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------- Custom Scan (DecompressChunk) on _hyper_13_20_chunk - -> Sort - Sort Key: compress_hyper_14_21_chunk._ts_meta_min_1, compress_hyper_14_21_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_14_21_chunk -(4 rows) + -> Index Scan Backward using compress_hyper_14_21_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_14_21_chunk +(2 rows) INSERT INTO test_ordering SELECT 1; -- should not be ordered append @@ -807,39 +805,35 @@ INSERT INTO test_ordering SELECT 1; -- It was hard to include a path without pushed down sort for consideration, as `add_path` would reject -- the path with sort pushdown, which is desirable in most cases :PREFIX SELECT * FROM test_ordering ORDER BY 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_ordering Order: test_ordering."time" -> Merge Append Sort Key: _hyper_13_20_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_13_20_chunk - -> Sort - Sort Key: compress_hyper_14_21_chunk._ts_meta_min_1, compress_hyper_14_21_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_14_21_chunk + -> Index Scan Backward using compress_hyper_14_21_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_14_21_chunk -> Sort Sort Key: _hyper_13_20_chunk."time" -> Seq Scan on _hyper_13_20_chunk -(11 rows) +(9 rows) INSERT INTO test_ordering VALUES (105),(104),(103); -- should be ordered append :PREFIX SELECT * FROM test_ordering ORDER BY 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_ordering Order: test_ordering."time" -> Merge Append Sort Key: _hyper_13_20_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_13_20_chunk - -> Sort - Sort Key: compress_hyper_14_21_chunk._ts_meta_min_1, compress_hyper_14_21_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_14_21_chunk + -> Index Scan Backward using compress_hyper_14_21_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_14_21_chunk -> Sort Sort Key: _hyper_13_20_chunk."time" -> Seq Scan on _hyper_13_20_chunk -> Index Only Scan Backward using _hyper_13_22_chunk_test_ordering_time_idx on _hyper_13_22_chunk -(12 rows) +(10 rows) --insert into compressed + uncompressed chunk INSERT INTO test_ordering VALUES (21), (22),(113); @@ -881,19 +875,15 @@ SELECT compress_chunk(format('%I.%I',chunk_schema,chunk_name), true) FROM timesc -- should be ordered append :PREFIX SELECT * FROM test_ordering ORDER BY 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_ordering Order: test_ordering."time" -> Custom Scan (DecompressChunk) on _hyper_13_20_chunk - -> Sort - Sort Key: compress_hyper_14_23_chunk._ts_meta_min_1, compress_hyper_14_23_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_14_23_chunk + -> Index Scan Backward using compress_hyper_14_21_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_14_21_chunk -> Custom Scan (DecompressChunk) on _hyper_13_22_chunk - -> Sort - Sort Key: compress_hyper_14_24_chunk._ts_meta_min_1, compress_hyper_14_24_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_14_24_chunk -(10 rows) + -> Index Scan Backward using compress_hyper_14_23_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_14_23_chunk +(6 rows) SET timescaledb.enable_decompression_sorted_merge = 1; -- TEST cagg triggers with insert into compressed chunk @@ -930,7 +920,7 @@ NOTICE: default order by for hypertable "conditions" is set to "timec DESC" SELECT compress_chunk(ch) FROM show_chunks('conditions') ch; compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_15_25_chunk + _timescaledb_internal._hyper_15_24_chunk (1 row) SELECT chunk_name, range_start, range_end, is_compressed @@ -938,7 +928,7 @@ FROM timescaledb_information.chunks WHERE hypertable_name = 'conditions'; chunk_name | range_start | range_end | is_compressed --------------------+------------------------------+------------------------------+--------------- - _hyper_15_25_chunk | Wed Dec 30 16:00:00 2009 PST | Wed Jan 06 16:00:00 2010 PST | t + _hyper_15_24_chunk | Wed Dec 30 16:00:00 2009 PST | Wed Jan 06 16:00:00 2010 PST | t (1 row) --now insert into compressed chunk @@ -1091,11 +1081,11 @@ SET timescaledb.max_tuples_decompressed_per_dml_transaction = 1; \set ON_ERROR_STOP 0 -- Inserting in the same period should decompress tuples INSERT INTO test_limit SELECT t, 2 FROM generate_series(1,6000,1000) t; -ERROR: duplicate key value violates unique constraint "_hyper_24_54_chunk_timestamp_id_idx" +ERROR: duplicate key value violates unique constraint "_hyper_24_53_chunk_timestamp_id_idx" -- Setting to 0 should remove the limit. SET timescaledb.max_tuples_decompressed_per_dml_transaction = 0; INSERT INTO test_limit SELECT t, 2 FROM generate_series(1,6000,1000) t; -ERROR: duplicate key value violates unique constraint "_hyper_24_54_chunk_timestamp_id_idx" +ERROR: duplicate key value violates unique constraint "_hyper_24_53_chunk_timestamp_id_idx" \set ON_ERROR_STOP 1 DROP TABLE test_limit; RESET timescaledb.max_tuples_decompressed_per_dml_transaction; @@ -1119,13 +1109,13 @@ SELECT count(compress_chunk(c)) FROM show_chunks('multi_unique') c; \set ON_ERROR_STOP 0 -- all INSERTS should fail with constraint violation BEGIN; INSERT INTO multi_unique VALUES('2024-01-01', 0, 0, 1.0); ROLLBACK; -ERROR: duplicate key value violates unique constraint "76_1_multi_unique_time_u1_key" +ERROR: duplicate key value violates unique constraint "75_1_multi_unique_time_u1_key" DETAIL: Key ("time", u1)=(Mon Jan 01 00:00:00 2024 PST, 0) already exists. BEGIN; INSERT INTO multi_unique VALUES('2024-01-01', 0, 1, 1.0); ROLLBACK; -ERROR: duplicate key value violates unique constraint "76_1_multi_unique_time_u1_key" +ERROR: duplicate key value violates unique constraint "75_1_multi_unique_time_u1_key" DETAIL: Key ("time", u1)=(Mon Jan 01 00:00:00 2024 PST, 0) already exists. BEGIN; INSERT INTO multi_unique VALUES('2024-01-01', 1, 0, 1.0); ROLLBACK; -ERROR: duplicate key value violates unique constraint "76_2_multi_unique_time_u2_key" +ERROR: duplicate key value violates unique constraint "75_2_multi_unique_time_u2_key" DETAIL: Key ("time", u2)=(Mon Jan 01 00:00:00 2024 PST, 0) already exists. \set ON_ERROR_STOP 1 DROP TABLE multi_unique; @@ -1149,7 +1139,7 @@ SELECT count(compress_chunk(c)) FROM show_chunks('unique_null') c; \set ON_ERROR_STOP 0 -- all INSERTS should fail with constraint violation BEGIN; INSERT INTO unique_null VALUES('2024-01-01', 0, 0, 1.0); ROLLBACK; -ERROR: duplicate key value violates unique constraint "78_3_unique_null_time_u1_u2_key" +ERROR: duplicate key value violates unique constraint "77_3_unique_null_time_u1_u2_key" \set ON_ERROR_STOP 1 -- neither of these should need to decompress :ANALYZE INSERT INTO unique_null VALUES('2024-01-01', NULL, 1, 1.0); diff --git a/tsl/test/expected/compression_qualpushdown.out b/tsl/test/expected/compression_qualpushdown.out index 7914e82cd06..f1baf41e932 100644 --- a/tsl/test/expected/compression_qualpushdown.out +++ b/tsl/test/expected/compression_qualpushdown.out @@ -135,9 +135,9 @@ order by factorid, end_dt; Output: _hyper_3_4_chunk.factorid, _hyper_3_4_chunk.end_dt, _hyper_3_4_chunk.logret Filter: ((_hyper_3_4_chunk.end_dt >= '12-10-2012'::date) AND (_hyper_3_4_chunk.end_dt <= '12-11-2012'::date)) Vectorized Filter: (_hyper_3_4_chunk.fmid = 56) - -> Seq Scan on _timescaledb_internal.compress_hyper_4_5_chunk + -> Index Scan using compress_hyper_4_5_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_4_5_chunk Output: compress_hyper_4_5_chunk._ts_meta_count, compress_hyper_4_5_chunk.fmid, compress_hyper_4_5_chunk.factorid, compress_hyper_4_5_chunk.start_dt, compress_hyper_4_5_chunk._ts_meta_min_1, compress_hyper_4_5_chunk._ts_meta_max_1, compress_hyper_4_5_chunk.end_dt, compress_hyper_4_5_chunk.interval_number, compress_hyper_4_5_chunk.logret, compress_hyper_4_5_chunk.knowledge_date - Filter: ((compress_hyper_4_5_chunk._ts_meta_max_1 >= '12-10-2012'::date) AND (compress_hyper_4_5_chunk._ts_meta_min_1 <= '12-11-2012'::date)) + Index Cond: ((compress_hyper_4_5_chunk._ts_meta_min_1 <= '12-11-2012'::date) AND (compress_hyper_4_5_chunk._ts_meta_max_1 >= '12-10-2012'::date)) (10 rows) --no pushdown here diff --git a/tsl/test/expected/compression_sequence_num_removal.out b/tsl/test/expected/compression_sequence_num_removal.out index 49c102455cf..b810ae44c0b 100644 --- a/tsl/test/expected/compression_sequence_num_removal.out +++ b/tsl/test/expected/compression_sequence_num_removal.out @@ -310,8 +310,8 @@ SELECT compress_chunk(show_chunks('hyper')); :EXPLAIN SELECT * FROM hyper ORDER BY time; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on public.hyper Output: hyper."time", hyper.device_id, hyper.val Order: hyper."time" @@ -319,33 +319,21 @@ ORDER BY time; Runtime Exclusion: false -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_10_chunk Output: _hyper_1_10_chunk."time", _hyper_1_10_chunk.device_id, _hyper_1_10_chunk.val - -> Sort + -> Index Scan using compress_hyper_2_14_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_2_14_chunk Output: compress_hyper_2_14_chunk._ts_meta_count, compress_hyper_2_14_chunk._ts_meta_min_1, compress_hyper_2_14_chunk._ts_meta_max_1, compress_hyper_2_14_chunk."time", compress_hyper_2_14_chunk.device_id, compress_hyper_2_14_chunk.val - Sort Key: compress_hyper_2_14_chunk._ts_meta_min_1, compress_hyper_2_14_chunk._ts_meta_max_1 - -> Seq Scan on _timescaledb_internal.compress_hyper_2_14_chunk - Output: compress_hyper_2_14_chunk._ts_meta_count, compress_hyper_2_14_chunk._ts_meta_min_1, compress_hyper_2_14_chunk._ts_meta_max_1, compress_hyper_2_14_chunk."time", compress_hyper_2_14_chunk.device_id, compress_hyper_2_14_chunk.val -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_11_chunk Output: _hyper_1_11_chunk."time", _hyper_1_11_chunk.device_id, _hyper_1_11_chunk.val - -> Sort + -> Index Scan using compress_hyper_2_15_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_2_15_chunk Output: compress_hyper_2_15_chunk._ts_meta_count, compress_hyper_2_15_chunk._ts_meta_min_1, compress_hyper_2_15_chunk._ts_meta_max_1, compress_hyper_2_15_chunk."time", compress_hyper_2_15_chunk.device_id, compress_hyper_2_15_chunk.val - Sort Key: compress_hyper_2_15_chunk._ts_meta_min_1, compress_hyper_2_15_chunk._ts_meta_max_1 - -> Seq Scan on _timescaledb_internal.compress_hyper_2_15_chunk - Output: compress_hyper_2_15_chunk._ts_meta_count, compress_hyper_2_15_chunk._ts_meta_min_1, compress_hyper_2_15_chunk._ts_meta_max_1, compress_hyper_2_15_chunk."time", compress_hyper_2_15_chunk.device_id, compress_hyper_2_15_chunk.val -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_12_chunk Output: _hyper_1_12_chunk."time", _hyper_1_12_chunk.device_id, _hyper_1_12_chunk.val - -> Sort + -> Index Scan using compress_hyper_2_16_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_2_16_chunk Output: compress_hyper_2_16_chunk._ts_meta_count, compress_hyper_2_16_chunk._ts_meta_min_1, compress_hyper_2_16_chunk._ts_meta_max_1, compress_hyper_2_16_chunk."time", compress_hyper_2_16_chunk.device_id, compress_hyper_2_16_chunk.val - Sort Key: compress_hyper_2_16_chunk._ts_meta_min_1, compress_hyper_2_16_chunk._ts_meta_max_1 - -> Seq Scan on _timescaledb_internal.compress_hyper_2_16_chunk - Output: compress_hyper_2_16_chunk._ts_meta_count, compress_hyper_2_16_chunk._ts_meta_min_1, compress_hyper_2_16_chunk._ts_meta_max_1, compress_hyper_2_16_chunk."time", compress_hyper_2_16_chunk.device_id, compress_hyper_2_16_chunk.val -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_13_chunk Output: _hyper_1_13_chunk."time", _hyper_1_13_chunk.device_id, _hyper_1_13_chunk.val - -> Sort + -> Index Scan using compress_hyper_2_17_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_2_17_chunk Output: compress_hyper_2_17_chunk._ts_meta_count, compress_hyper_2_17_chunk._ts_meta_min_1, compress_hyper_2_17_chunk._ts_meta_max_1, compress_hyper_2_17_chunk."time", compress_hyper_2_17_chunk.device_id, compress_hyper_2_17_chunk.val - Sort Key: compress_hyper_2_17_chunk._ts_meta_min_1, compress_hyper_2_17_chunk._ts_meta_max_1 - -> Seq Scan on _timescaledb_internal.compress_hyper_2_17_chunk - Output: compress_hyper_2_17_chunk._ts_meta_count, compress_hyper_2_17_chunk._ts_meta_min_1, compress_hyper_2_17_chunk._ts_meta_max_1, compress_hyper_2_17_chunk."time", compress_hyper_2_17_chunk.device_id, compress_hyper_2_17_chunk.val -(33 rows) +(21 rows) -- modify two chunks by adding sequence number to the segments SELECT comp_ch.table_name AS "CHUNK_NAME", comp_ch.schema_name|| '.' || comp_ch.table_name AS "CHUNK_FULL_NAME" @@ -399,18 +387,12 @@ ORDER BY time; Output: compress_hyper_2_14_chunk._ts_meta_count, compress_hyper_2_14_chunk._ts_meta_min_1, compress_hyper_2_14_chunk._ts_meta_max_1, compress_hyper_2_14_chunk."time", compress_hyper_2_14_chunk.device_id, compress_hyper_2_14_chunk.val, compress_hyper_2_14_chunk._ts_meta_sequence_num -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_11_chunk Output: _hyper_1_11_chunk."time", _hyper_1_11_chunk.device_id, _hyper_1_11_chunk.val - -> Sort + -> Index Scan using compress_hyper_2_15_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_2_15_chunk Output: compress_hyper_2_15_chunk._ts_meta_count, compress_hyper_2_15_chunk._ts_meta_min_1, compress_hyper_2_15_chunk._ts_meta_max_1, compress_hyper_2_15_chunk."time", compress_hyper_2_15_chunk.device_id, compress_hyper_2_15_chunk.val - Sort Key: compress_hyper_2_15_chunk._ts_meta_min_1, compress_hyper_2_15_chunk._ts_meta_max_1 - -> Seq Scan on _timescaledb_internal.compress_hyper_2_15_chunk - Output: compress_hyper_2_15_chunk._ts_meta_count, compress_hyper_2_15_chunk._ts_meta_min_1, compress_hyper_2_15_chunk._ts_meta_max_1, compress_hyper_2_15_chunk."time", compress_hyper_2_15_chunk.device_id, compress_hyper_2_15_chunk.val -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_12_chunk Output: _hyper_1_12_chunk."time", _hyper_1_12_chunk.device_id, _hyper_1_12_chunk.val - -> Sort + -> Index Scan using compress_hyper_2_16_chunk__ts_meta_min_1__ts_meta_max_1_idx on _timescaledb_internal.compress_hyper_2_16_chunk Output: compress_hyper_2_16_chunk._ts_meta_count, compress_hyper_2_16_chunk._ts_meta_min_1, compress_hyper_2_16_chunk._ts_meta_max_1, compress_hyper_2_16_chunk."time", compress_hyper_2_16_chunk.device_id, compress_hyper_2_16_chunk.val - Sort Key: compress_hyper_2_16_chunk._ts_meta_min_1, compress_hyper_2_16_chunk._ts_meta_max_1 - -> Seq Scan on _timescaledb_internal.compress_hyper_2_16_chunk - Output: compress_hyper_2_16_chunk._ts_meta_count, compress_hyper_2_16_chunk._ts_meta_min_1, compress_hyper_2_16_chunk._ts_meta_max_1, compress_hyper_2_16_chunk."time", compress_hyper_2_16_chunk.device_id, compress_hyper_2_16_chunk.val -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_13_chunk Output: _hyper_1_13_chunk."time", _hyper_1_13_chunk.device_id, _hyper_1_13_chunk.val -> Sort @@ -418,7 +400,7 @@ ORDER BY time; Sort Key: compress_hyper_2_17_chunk._ts_meta_sequence_num -> Seq Scan on _timescaledb_internal.compress_hyper_2_17_chunk Output: compress_hyper_2_17_chunk._ts_meta_count, compress_hyper_2_17_chunk._ts_meta_min_1, compress_hyper_2_17_chunk._ts_meta_max_1, compress_hyper_2_17_chunk."time", compress_hyper_2_17_chunk.device_id, compress_hyper_2_17_chunk.val, compress_hyper_2_17_chunk._ts_meta_sequence_num -(33 rows) +(27 rows) -- test rolling up chunks during compression -- this will not work with chunks which have sequence numbers diff --git a/tsl/test/expected/compression_update_delete-14.out b/tsl/test/expected/compression_update_delete-14.out index d31b39d057a..c376989181b 100644 --- a/tsl/test/expected/compression_update_delete-14.out +++ b/tsl/test/expected/compression_update_delete-14.out @@ -2779,23 +2779,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2844,38 +2838,32 @@ EXPLAIN (costs off) DELETE FROM test_partials WHERE time >= ALL(SELECT time from DELETE FROM test_partials WHERE time >= ALL(SELECT time from test_partials); -- All 3 chunks will now become partially compressed chunks EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_35_68_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Sort Sort Key: _hyper_35_68_chunk."time" -> Seq Scan on _hyper_35_68_chunk -> Merge Append Sort Key: _hyper_35_69_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Sort Sort Key: _hyper_35_69_chunk."time" -> Seq Scan on _hyper_35_69_chunk -> Merge Append Sort Key: _hyper_35_70_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk -> Sort Sort Key: _hyper_35_70_chunk."time" -> Seq Scan on _hyper_35_70_chunk -(29 rows) +(23 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2899,23 +2887,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_74_chunk._ts_meta_min_1, compress_hyper_36_74_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_74_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_75_chunk._ts_meta_min_1, compress_hyper_36_75_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_75_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_76_chunk._ts_meta_min_1, compress_hyper_36_76_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_76_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) DROP TABLE test_partials; CREATE TABLE test_meta_filters(time timestamptz NOT NULL, device text, metric text, v1 float, v2 float); @@ -2931,7 +2913,7 @@ INSERT INTO test_meta_filters SELECT '2020-01-01'::timestamptz,'d1','m' || metri SELECT compress_chunk(show_chunks('test_meta_filters')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_37_77_chunk + _timescaledb_internal._hyper_37_74_chunk (1 row) EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filters WHERE device = 'd1' AND metric = 'm1' AND v1 < 100; @@ -2941,8 +2923,8 @@ EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filt Batches decompressed: 1 Tuples decompressed: 1000 -> Delete on test_meta_filters (actual rows=0 loops=1) - Delete on _hyper_37_77_chunk test_meta_filters_1 - -> Seq Scan on _hyper_37_77_chunk test_meta_filters_1 (actual rows=990 loops=1) + Delete on _hyper_37_74_chunk test_meta_filters_1 + -> Seq Scan on _hyper_37_74_chunk test_meta_filters_1 (actual rows=990 loops=1) Filter: ((v1 < '100'::double precision) AND (device = 'd1'::text) AND (metric = 'm1'::text)) Rows Removed by Filter: 10 (8 rows) @@ -2969,7 +2951,7 @@ NOTICE: default order by for hypertable "test_pushdown" is set to ""time" DESC" SELECT compress_chunk(show_chunks('test_pushdown')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_39_79_chunk + _timescaledb_internal._hyper_39_76_chunk (1 row) -- 3 batch decompressions means pushdown is not working so we expect less than 3 for all these queries @@ -2981,8 +2963,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'a' = device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('a'::text = device) (7 rows) @@ -2993,8 +2975,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device < 'c' ; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: (device < 'c'::text) (7 rows) @@ -3005,8 +2987,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' > device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('c'::text > device) (7 rows) @@ -3017,8 +2999,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' >= device; ROLLBACK; Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=3 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=3 loops=1) Filter: ('c'::text >= device) (7 rows) @@ -3029,8 +3011,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device > 'b'; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device > 'b'::text) (7 rows) @@ -3039,10 +3021,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = CURRENT_USER; ROLLBACK; ------------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = CURRENT_USER) (7 rows) @@ -3053,8 +3035,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' < device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('b'::text < device) (7 rows) @@ -3065,8 +3047,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' <= device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('b'::text <= device) (7 rows) @@ -3079,8 +3061,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = 'a' OR device = 'b'; RO Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ((device = 'a'::text) OR (device = 'b'::text)) Rows Removed by Filter: 1 (8 rows) @@ -3093,8 +3075,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time = timestamptz('2020-01-01 0 Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ("time" = 'Wed Jan 01 05:00:00 2020 PST'::timestamp with time zone) (7 rows) @@ -3106,10 +3088,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = substring(CURRENT_USER, Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ("substring"((CURRENT_USER)::text, (length((CURRENT_USER)::text) + 1)) || 'c'::text)) (9 rows) @@ -3123,13 +3105,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3150,13 +3132,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3178,13 +3160,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3202,13 +3184,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3228,8 +3210,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = 'a'::text) (7 rows) @@ -3240,8 +3222,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'a'::text) (6 rows) @@ -3250,8 +3232,8 @@ BEGIN; :EXPLAIN EXECUTE q1('not here'); ROLLBACK; ------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'not here'::text) (5 rows) @@ -3262,8 +3244,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a','d'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3273,8 +3255,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = ANY('{a,d}'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3285,10 +3267,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',CURRENT_USER); RO Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, (CURRENT_USER)::text])) (9 rows) @@ -3300,8 +3282,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time IN ('2020-01-01','2020-01-0 Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ("time" = ANY ('{"Wed Jan 01 00:00:00 2020 PST","Thu Jan 02 00:00:00 2020 PST"}'::timestamp with time zone[])) Rows Removed by Filter: 1 (8 rows) @@ -3314,10 +3296,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = current_query(); ROLLBA Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = current_query()) Rows Removed by Filter: 3 (10 rows) @@ -3329,10 +3311,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',current_query()); Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, current_query()])) Rows Removed by Filter: 2 (10 rows) @@ -3378,7 +3360,7 @@ NOTICE: default order by for hypertable "update_trigger_test" is set to "effect SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; @@ -3389,14 +3371,14 @@ ROLLBACK; SELECT decompress_chunk(show_chunks('update_trigger_test')); decompress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) ALTER TABLE update_trigger_test SET (timescaledb.compress, timescaledb.compress_segmentby='entity_id'); SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; diff --git a/tsl/test/expected/compression_update_delete-15.out b/tsl/test/expected/compression_update_delete-15.out index d31b39d057a..c376989181b 100644 --- a/tsl/test/expected/compression_update_delete-15.out +++ b/tsl/test/expected/compression_update_delete-15.out @@ -2779,23 +2779,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2844,38 +2838,32 @@ EXPLAIN (costs off) DELETE FROM test_partials WHERE time >= ALL(SELECT time from DELETE FROM test_partials WHERE time >= ALL(SELECT time from test_partials); -- All 3 chunks will now become partially compressed chunks EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_35_68_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Sort Sort Key: _hyper_35_68_chunk."time" -> Seq Scan on _hyper_35_68_chunk -> Merge Append Sort Key: _hyper_35_69_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Sort Sort Key: _hyper_35_69_chunk."time" -> Seq Scan on _hyper_35_69_chunk -> Merge Append Sort Key: _hyper_35_70_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk -> Sort Sort Key: _hyper_35_70_chunk."time" -> Seq Scan on _hyper_35_70_chunk -(29 rows) +(23 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2899,23 +2887,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_74_chunk._ts_meta_min_1, compress_hyper_36_74_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_74_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_75_chunk._ts_meta_min_1, compress_hyper_36_75_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_75_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_76_chunk._ts_meta_min_1, compress_hyper_36_76_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_76_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) DROP TABLE test_partials; CREATE TABLE test_meta_filters(time timestamptz NOT NULL, device text, metric text, v1 float, v2 float); @@ -2931,7 +2913,7 @@ INSERT INTO test_meta_filters SELECT '2020-01-01'::timestamptz,'d1','m' || metri SELECT compress_chunk(show_chunks('test_meta_filters')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_37_77_chunk + _timescaledb_internal._hyper_37_74_chunk (1 row) EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filters WHERE device = 'd1' AND metric = 'm1' AND v1 < 100; @@ -2941,8 +2923,8 @@ EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filt Batches decompressed: 1 Tuples decompressed: 1000 -> Delete on test_meta_filters (actual rows=0 loops=1) - Delete on _hyper_37_77_chunk test_meta_filters_1 - -> Seq Scan on _hyper_37_77_chunk test_meta_filters_1 (actual rows=990 loops=1) + Delete on _hyper_37_74_chunk test_meta_filters_1 + -> Seq Scan on _hyper_37_74_chunk test_meta_filters_1 (actual rows=990 loops=1) Filter: ((v1 < '100'::double precision) AND (device = 'd1'::text) AND (metric = 'm1'::text)) Rows Removed by Filter: 10 (8 rows) @@ -2969,7 +2951,7 @@ NOTICE: default order by for hypertable "test_pushdown" is set to ""time" DESC" SELECT compress_chunk(show_chunks('test_pushdown')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_39_79_chunk + _timescaledb_internal._hyper_39_76_chunk (1 row) -- 3 batch decompressions means pushdown is not working so we expect less than 3 for all these queries @@ -2981,8 +2963,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'a' = device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('a'::text = device) (7 rows) @@ -2993,8 +2975,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device < 'c' ; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: (device < 'c'::text) (7 rows) @@ -3005,8 +2987,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' > device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('c'::text > device) (7 rows) @@ -3017,8 +2999,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' >= device; ROLLBACK; Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=3 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=3 loops=1) Filter: ('c'::text >= device) (7 rows) @@ -3029,8 +3011,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device > 'b'; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device > 'b'::text) (7 rows) @@ -3039,10 +3021,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = CURRENT_USER; ROLLBACK; ------------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = CURRENT_USER) (7 rows) @@ -3053,8 +3035,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' < device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('b'::text < device) (7 rows) @@ -3065,8 +3047,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' <= device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('b'::text <= device) (7 rows) @@ -3079,8 +3061,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = 'a' OR device = 'b'; RO Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ((device = 'a'::text) OR (device = 'b'::text)) Rows Removed by Filter: 1 (8 rows) @@ -3093,8 +3075,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time = timestamptz('2020-01-01 0 Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ("time" = 'Wed Jan 01 05:00:00 2020 PST'::timestamp with time zone) (7 rows) @@ -3106,10 +3088,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = substring(CURRENT_USER, Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ("substring"((CURRENT_USER)::text, (length((CURRENT_USER)::text) + 1)) || 'c'::text)) (9 rows) @@ -3123,13 +3105,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3150,13 +3132,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3178,13 +3160,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3202,13 +3184,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3228,8 +3210,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = 'a'::text) (7 rows) @@ -3240,8 +3222,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'a'::text) (6 rows) @@ -3250,8 +3232,8 @@ BEGIN; :EXPLAIN EXECUTE q1('not here'); ROLLBACK; ------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'not here'::text) (5 rows) @@ -3262,8 +3244,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a','d'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3273,8 +3255,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = ANY('{a,d}'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3285,10 +3267,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',CURRENT_USER); RO Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, (CURRENT_USER)::text])) (9 rows) @@ -3300,8 +3282,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time IN ('2020-01-01','2020-01-0 Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ("time" = ANY ('{"Wed Jan 01 00:00:00 2020 PST","Thu Jan 02 00:00:00 2020 PST"}'::timestamp with time zone[])) Rows Removed by Filter: 1 (8 rows) @@ -3314,10 +3296,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = current_query(); ROLLBA Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = current_query()) Rows Removed by Filter: 3 (10 rows) @@ -3329,10 +3311,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',current_query()); Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, current_query()])) Rows Removed by Filter: 2 (10 rows) @@ -3378,7 +3360,7 @@ NOTICE: default order by for hypertable "update_trigger_test" is set to "effect SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; @@ -3389,14 +3371,14 @@ ROLLBACK; SELECT decompress_chunk(show_chunks('update_trigger_test')); decompress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) ALTER TABLE update_trigger_test SET (timescaledb.compress, timescaledb.compress_segmentby='entity_id'); SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; diff --git a/tsl/test/expected/compression_update_delete-16.out b/tsl/test/expected/compression_update_delete-16.out index d31b39d057a..c376989181b 100644 --- a/tsl/test/expected/compression_update_delete-16.out +++ b/tsl/test/expected/compression_update_delete-16.out @@ -2779,23 +2779,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2844,38 +2838,32 @@ EXPLAIN (costs off) DELETE FROM test_partials WHERE time >= ALL(SELECT time from DELETE FROM test_partials WHERE time >= ALL(SELECT time from test_partials); -- All 3 chunks will now become partially compressed chunks EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_35_68_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Sort Sort Key: _hyper_35_68_chunk."time" -> Seq Scan on _hyper_35_68_chunk -> Merge Append Sort Key: _hyper_35_69_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Sort Sort Key: _hyper_35_69_chunk."time" -> Seq Scan on _hyper_35_69_chunk -> Merge Append Sort Key: _hyper_35_70_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk -> Sort Sort Key: _hyper_35_70_chunk."time" -> Seq Scan on _hyper_35_70_chunk -(29 rows) +(23 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2899,23 +2887,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_74_chunk._ts_meta_min_1, compress_hyper_36_74_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_74_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_75_chunk._ts_meta_min_1, compress_hyper_36_75_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_75_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_76_chunk._ts_meta_min_1, compress_hyper_36_76_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_76_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) DROP TABLE test_partials; CREATE TABLE test_meta_filters(time timestamptz NOT NULL, device text, metric text, v1 float, v2 float); @@ -2931,7 +2913,7 @@ INSERT INTO test_meta_filters SELECT '2020-01-01'::timestamptz,'d1','m' || metri SELECT compress_chunk(show_chunks('test_meta_filters')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_37_77_chunk + _timescaledb_internal._hyper_37_74_chunk (1 row) EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filters WHERE device = 'd1' AND metric = 'm1' AND v1 < 100; @@ -2941,8 +2923,8 @@ EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filt Batches decompressed: 1 Tuples decompressed: 1000 -> Delete on test_meta_filters (actual rows=0 loops=1) - Delete on _hyper_37_77_chunk test_meta_filters_1 - -> Seq Scan on _hyper_37_77_chunk test_meta_filters_1 (actual rows=990 loops=1) + Delete on _hyper_37_74_chunk test_meta_filters_1 + -> Seq Scan on _hyper_37_74_chunk test_meta_filters_1 (actual rows=990 loops=1) Filter: ((v1 < '100'::double precision) AND (device = 'd1'::text) AND (metric = 'm1'::text)) Rows Removed by Filter: 10 (8 rows) @@ -2969,7 +2951,7 @@ NOTICE: default order by for hypertable "test_pushdown" is set to ""time" DESC" SELECT compress_chunk(show_chunks('test_pushdown')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_39_79_chunk + _timescaledb_internal._hyper_39_76_chunk (1 row) -- 3 batch decompressions means pushdown is not working so we expect less than 3 for all these queries @@ -2981,8 +2963,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'a' = device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('a'::text = device) (7 rows) @@ -2993,8 +2975,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device < 'c' ; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: (device < 'c'::text) (7 rows) @@ -3005,8 +2987,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' > device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('c'::text > device) (7 rows) @@ -3017,8 +2999,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' >= device; ROLLBACK; Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=3 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=3 loops=1) Filter: ('c'::text >= device) (7 rows) @@ -3029,8 +3011,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device > 'b'; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device > 'b'::text) (7 rows) @@ -3039,10 +3021,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = CURRENT_USER; ROLLBACK; ------------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = CURRENT_USER) (7 rows) @@ -3053,8 +3035,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' < device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('b'::text < device) (7 rows) @@ -3065,8 +3047,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' <= device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('b'::text <= device) (7 rows) @@ -3079,8 +3061,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = 'a' OR device = 'b'; RO Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ((device = 'a'::text) OR (device = 'b'::text)) Rows Removed by Filter: 1 (8 rows) @@ -3093,8 +3075,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time = timestamptz('2020-01-01 0 Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ("time" = 'Wed Jan 01 05:00:00 2020 PST'::timestamp with time zone) (7 rows) @@ -3106,10 +3088,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = substring(CURRENT_USER, Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ("substring"((CURRENT_USER)::text, (length((CURRENT_USER)::text) + 1)) || 'c'::text)) (9 rows) @@ -3123,13 +3105,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3150,13 +3132,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3178,13 +3160,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3202,13 +3184,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3228,8 +3210,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = 'a'::text) (7 rows) @@ -3240,8 +3222,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'a'::text) (6 rows) @@ -3250,8 +3232,8 @@ BEGIN; :EXPLAIN EXECUTE q1('not here'); ROLLBACK; ------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'not here'::text) (5 rows) @@ -3262,8 +3244,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a','d'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3273,8 +3255,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = ANY('{a,d}'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3285,10 +3267,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',CURRENT_USER); RO Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, (CURRENT_USER)::text])) (9 rows) @@ -3300,8 +3282,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time IN ('2020-01-01','2020-01-0 Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ("time" = ANY ('{"Wed Jan 01 00:00:00 2020 PST","Thu Jan 02 00:00:00 2020 PST"}'::timestamp with time zone[])) Rows Removed by Filter: 1 (8 rows) @@ -3314,10 +3296,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = current_query(); ROLLBA Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = current_query()) Rows Removed by Filter: 3 (10 rows) @@ -3329,10 +3311,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',current_query()); Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, current_query()])) Rows Removed by Filter: 2 (10 rows) @@ -3378,7 +3360,7 @@ NOTICE: default order by for hypertable "update_trigger_test" is set to "effect SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; @@ -3389,14 +3371,14 @@ ROLLBACK; SELECT decompress_chunk(show_chunks('update_trigger_test')); decompress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) ALTER TABLE update_trigger_test SET (timescaledb.compress, timescaledb.compress_segmentby='entity_id'); SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; diff --git a/tsl/test/expected/compression_update_delete-17.out b/tsl/test/expected/compression_update_delete-17.out index 5808f1ba88e..d921cc88a39 100644 --- a/tsl/test/expected/compression_update_delete-17.out +++ b/tsl/test/expected/compression_update_delete-17.out @@ -2779,23 +2779,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2844,38 +2838,32 @@ EXPLAIN (costs off) DELETE FROM test_partials WHERE time >= ALL(SELECT time from DELETE FROM test_partials WHERE time >= ALL(SELECT time from test_partials); -- All 3 chunks will now become partially compressed chunks EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Merge Append Sort Key: _hyper_35_68_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_71_chunk._ts_meta_min_1, compress_hyper_36_71_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_71_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Sort Sort Key: _hyper_35_68_chunk."time" -> Seq Scan on _hyper_35_68_chunk -> Merge Append Sort Key: _hyper_35_69_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_72_chunk._ts_meta_min_1, compress_hyper_36_72_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_72_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Sort Sort Key: _hyper_35_69_chunk."time" -> Seq Scan on _hyper_35_69_chunk -> Merge Append Sort Key: _hyper_35_70_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_73_chunk._ts_meta_min_1, compress_hyper_36_73_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_73_chunk + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk -> Sort Sort Key: _hyper_35_70_chunk."time" -> Seq Scan on _hyper_35_70_chunk -(29 rows) +(23 rows) -- verify correct results SELECT * FROM test_partials ORDER BY time; @@ -2899,23 +2887,17 @@ SELECT compress_chunk(show_chunks('test_partials')); -- fully compressed EXPLAIN (costs off) SELECT * FROM test_partials ORDER BY time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- Custom Scan (ChunkAppend) on test_partials Order: test_partials."time" -> Custom Scan (DecompressChunk) on _hyper_35_68_chunk - -> Sort - Sort Key: compress_hyper_36_74_chunk._ts_meta_min_1, compress_hyper_36_74_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_74_chunk + -> Index Scan Backward using compress_hyper_36_71_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_71_chunk -> Custom Scan (DecompressChunk) on _hyper_35_69_chunk - -> Sort - Sort Key: compress_hyper_36_75_chunk._ts_meta_min_1, compress_hyper_36_75_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_75_chunk + -> Index Scan Backward using compress_hyper_36_72_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_72_chunk -> Custom Scan (DecompressChunk) on _hyper_35_70_chunk - -> Sort - Sort Key: compress_hyper_36_76_chunk._ts_meta_min_1, compress_hyper_36_76_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_36_76_chunk -(14 rows) + -> Index Scan Backward using compress_hyper_36_73_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_36_73_chunk +(8 rows) DROP TABLE test_partials; CREATE TABLE test_meta_filters(time timestamptz NOT NULL, device text, metric text, v1 float, v2 float); @@ -2931,7 +2913,7 @@ INSERT INTO test_meta_filters SELECT '2020-01-01'::timestamptz,'d1','m' || metri SELECT compress_chunk(show_chunks('test_meta_filters')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_37_77_chunk + _timescaledb_internal._hyper_37_74_chunk (1 row) EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filters WHERE device = 'd1' AND metric = 'm1' AND v1 < 100; @@ -2941,8 +2923,8 @@ EXPLAIN (analyze, timing off, costs off, summary off) DELETE FROM test_meta_filt Batches decompressed: 1 Tuples decompressed: 1000 -> Delete on test_meta_filters (actual rows=0 loops=1) - Delete on _hyper_37_77_chunk test_meta_filters_1 - -> Seq Scan on _hyper_37_77_chunk test_meta_filters_1 (actual rows=990 loops=1) + Delete on _hyper_37_74_chunk test_meta_filters_1 + -> Seq Scan on _hyper_37_74_chunk test_meta_filters_1 (actual rows=990 loops=1) Filter: ((v1 < '100'::double precision) AND (device = 'd1'::text) AND (metric = 'm1'::text)) Rows Removed by Filter: 10 (8 rows) @@ -2969,7 +2951,7 @@ NOTICE: default order by for hypertable "test_pushdown" is set to ""time" DESC" SELECT compress_chunk(show_chunks('test_pushdown')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_39_79_chunk + _timescaledb_internal._hyper_39_76_chunk (1 row) -- 3 batch decompressions means pushdown is not working so we expect less than 3 for all these queries @@ -2981,8 +2963,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'a' = device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('a'::text = device) (7 rows) @@ -2993,8 +2975,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device < 'c' ; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: (device < 'c'::text) (7 rows) @@ -3005,8 +2987,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' > device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('c'::text > device) (7 rows) @@ -3017,8 +2999,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'c' >= device; ROLLBACK; Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=3 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=3 loops=1) Filter: ('c'::text >= device) (7 rows) @@ -3029,8 +3011,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device > 'b'; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device > 'b'::text) (7 rows) @@ -3039,10 +3021,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = CURRENT_USER; ROLLBACK; ------------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = CURRENT_USER) (7 rows) @@ -3053,8 +3035,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' < device; ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ('b'::text < device) (7 rows) @@ -3065,8 +3047,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE 'b' <= device; ROLLBACK; Batches decompressed: 2 Tuples decompressed: 2 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ('b'::text <= device) (7 rows) @@ -3079,8 +3061,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = 'a' OR device = 'b'; RO Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ((device = 'a'::text) OR (device = 'b'::text)) Rows Removed by Filter: 1 (8 rows) @@ -3093,8 +3075,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time = timestamptz('2020-01-01 0 Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: ("time" = 'Wed Jan 01 05:00:00 2020 PST'::timestamp with time zone) (7 rows) @@ -3106,10 +3088,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = substring(CURRENT_USER, Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ("substring"((CURRENT_USER)::text, (length((CURRENT_USER)::text) + 1)) || 'c'::text)) (9 rows) @@ -3123,13 +3105,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3150,13 +3132,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices3 d WHERE p.device=d.de Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Merge Join (actual rows=1 loops=1) Merge Cond: (p_1.device = d.device) -> Sort (actual rows=3 loops=1) Sort Key: p_1.device Sort Method: quicksort - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=3 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: d.device Sort Method: quicksort @@ -3178,13 +3160,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3202,13 +3184,13 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown p USING devices d WHERE p.device=d.dev Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown p (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk p_1 + Delete on _hyper_39_76_chunk p_1 -> Nested Loop (actual rows=1 loops=1) -> Seq Scan on devices d (actual rows=1 loops=1) Filter: (device = 'b'::text) Rows Removed by Filter: 2 -> Materialize (actual rows=1 loops=1) - -> Seq Scan on _hyper_39_79_chunk p_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk p_1 (actual rows=1 loops=1) Filter: (device = 'b'::text) (12 rows) @@ -3228,8 +3210,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = 'a'::text) (7 rows) @@ -3240,8 +3222,8 @@ BEGIN; :EXPLAIN EXECUTE q1('a'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'a'::text) (6 rows) @@ -3250,8 +3232,8 @@ BEGIN; :EXPLAIN EXECUTE q1('not here'); ROLLBACK; ------------------------------------------------------------------------------------ Custom Scan (HypertableModify) (actual rows=0 loops=1) -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = 'not here'::text) (5 rows) @@ -3262,8 +3244,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a','d'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3273,8 +3255,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = ANY('{a,d}'); ROLLBACK; Custom Scan (HypertableModify) (actual rows=0 loops=1) Batches deleted: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = ANY ('{a,d}'::text[])) (6 rows) @@ -3285,10 +3267,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',CURRENT_USER); RO Batches decompressed: 1 Tuples decompressed: 1 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, (CURRENT_USER)::text])) (9 rows) @@ -3300,8 +3282,8 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE time IN ('2020-01-01','2020-01-0 Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=2 loops=1) + Delete on _hyper_39_76_chunk test_pushdown_1 + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=2 loops=1) Filter: ("time" = ANY ('{"Wed Jan 01 00:00:00 2020 PST","Thu Jan 02 00:00:00 2020 PST"}'::timestamp with time zone[])) Rows Removed by Filter: 1 (8 rows) @@ -3314,10 +3296,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device = current_query(); ROLLBA Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=0 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=0 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=0 loops=1) Filter: (device = current_query()) Rows Removed by Filter: 3 (10 rows) @@ -3329,10 +3311,10 @@ BEGIN; :EXPLAIN DELETE FROM test_pushdown WHERE device IN ('a',current_query()); Batches decompressed: 3 Tuples decompressed: 3 -> Delete on test_pushdown (actual rows=0 loops=1) - Delete on _hyper_39_79_chunk test_pushdown_1 + Delete on _hyper_39_76_chunk test_pushdown_1 -> Custom Scan (ChunkAppend) on test_pushdown (actual rows=1 loops=1) Chunks excluded during startup: 0 - -> Seq Scan on _hyper_39_79_chunk test_pushdown_1 (actual rows=1 loops=1) + -> Seq Scan on _hyper_39_76_chunk test_pushdown_1 (actual rows=1 loops=1) Filter: (device = ANY (ARRAY['a'::text, current_query()])) Rows Removed by Filter: 2 (10 rows) @@ -3378,7 +3360,7 @@ NOTICE: default order by for hypertable "update_trigger_test" is set to "effect SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; @@ -3389,14 +3371,14 @@ ROLLBACK; SELECT decompress_chunk(show_chunks('update_trigger_test')); decompress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) ALTER TABLE update_trigger_test SET (timescaledb.compress, timescaledb.compress_segmentby='entity_id'); SELECT compress_chunk(show_chunks('update_trigger_test')); compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_41_81_chunk + _timescaledb_internal._hyper_41_78_chunk (1 row) BEGIN; diff --git a/tsl/test/expected/hypercore.out b/tsl/test/expected/hypercore.out index c4ff2450f9a..f59b9909287 100644 --- a/tsl/test/expected/hypercore.out +++ b/tsl/test/expected/hypercore.out @@ -763,7 +763,7 @@ select format('%I.%I', chunk_schema, chunk_name)::regclass as rescan_chunk select compress_chunk(:'rescan_chunk', hypercore_use_access_method => true); compress_chunk ----------------------------------------- - _timescaledb_internal._hyper_5_40_chunk + _timescaledb_internal._hyper_5_37_chunk (1 row) select relname, amname @@ -772,7 +772,7 @@ select relname, amname join pg_am on (relam = pg_am.oid); relname | amname -------------------+----------- - _hyper_5_40_chunk | hypercore + _hyper_5_37_chunk | hypercore (1 row) insert into rescan values ('2024-11-02 01:00', 2, 1.0), ('2024-11-02 02:00', 2, 2.0), ('2024-11-02 03:00', 1, 3.0), ('2024-11-02 05:00', 2, 4.0); diff --git a/tsl/test/expected/hypercore_vacuum.out b/tsl/test/expected/hypercore_vacuum.out index eab589787e3..502deddcdca 100644 --- a/tsl/test/expected/hypercore_vacuum.out +++ b/tsl/test/expected/hypercore_vacuum.out @@ -414,12 +414,15 @@ inner join pg_am am on (cl.relam = am.oid); select indexrelid::regclass from pg_index i inner join compressed_rels crels on (i.indrelid = crels.compressed_relid); - indexrelid ------------------------------------------------------------------------- + indexrelid +----------------------------------------------------------------------------------- _timescaledb_internal.compress_hyper_5_13_chunk_ts_hypercore_proxy_idx + _timescaledb_internal.compress_hyper_5_13_chunk__ts_meta_min_1__ts_meta_max_1_idx _timescaledb_internal.compress_hyper_5_14_chunk_ts_hypercore_proxy_idx + _timescaledb_internal.compress_hyper_5_14_chunk__ts_meta_min_1__ts_meta_max_1_idx _timescaledb_internal.compress_hyper_5_15_chunk_ts_hypercore_proxy_idx -(3 rows) + _timescaledb_internal.compress_hyper_5_15_chunk__ts_meta_min_1__ts_meta_max_1_idx +(6 rows) -- delete some data to generate garbage delete from hystable where temp > 20; diff --git a/tsl/test/expected/recompress_chunk_segmentwise.out b/tsl/test/expected/recompress_chunk_segmentwise.out index e1ef715b968..bfca5b0a91a 100644 --- a/tsl/test/expected/recompress_chunk_segmentwise.out +++ b/tsl/test/expected/recompress_chunk_segmentwise.out @@ -464,6 +464,7 @@ alter table mytab set (timescaledb.compress); WARNING: there was some uncertainty picking the default segment by for the hypertable: You do not have any indexes on columns that can be used for segment_by and thus we are not using segment_by for compression. Please make sure you are not missing any indexes NOTICE: default segment by for hypertable "mytab" is set to "" NOTICE: default order by for hypertable "mytab" is set to ""time" DESC" +SET timescaledb.enable_segmentwise_recompression TO OFF; select compress_chunk(show_chunks('mytab')); compress_chunk ------------------------------------------ @@ -474,6 +475,7 @@ select compressed_chunk_name as compressed_chunk_name_before_recompression from INSERT INTO mytab VALUES ('2023-01-01'::timestamptz, 2, 3, 2); -- expect to see a different compressed chunk after recompressing now as the operation is decompress + compress SELECT compress_chunk(:'chunk_to_compress_mytab'); +NOTICE: segmentwise recompression is disabled, performing full recompression on chunk "_timescaledb_internal._hyper_11_12_chunk" compress_chunk ------------------------------------------ _timescaledb_internal._hyper_11_12_chunk @@ -486,6 +488,7 @@ select :'compressed_chunk_name_before_recompression' as before_recompression, :' compress_hyper_13_14_chunk | compress_hyper_13_15_chunk (1 row) +RESET timescaledb.enable_segmentwise_recompression; -- check behavior with NULL values in segmentby columns select '2022-01-01 09:00:00+00' as start_time \gset create table nullseg_one (time timestamptz, a int, b int); diff --git a/tsl/test/expected/telemetry_stats.out b/tsl/test/expected/telemetry_stats.out index 5ad9ac55903..089cd6c70c5 100644 --- a/tsl/test/expected/telemetry_stats.out +++ b/tsl/test/expected/telemetry_stats.out @@ -328,13 +328,13 @@ SELECT jsonb_pretty(rels) AS relations FROM relations; "num_compressed_chunks": 5, + "uncompressed_heap_size": 221184, + "uncompressed_row_count": 736, + - "compressed_indexes_size": 16384, + + "compressed_indexes_size": 81920, + "uncompressed_toast_size": 0, + "uncompressed_indexes_size": 131072, + "num_compressed_hypertables": 2, + "compressed_row_count_frozen_immediately": 14+ }, + - "indexes_size": 204800, + + "indexes_size": 270336, + "num_children": 11, + "num_relations": 2, + "num_reltuples": 658 + diff --git a/tsl/test/expected/vector_agg_default.out b/tsl/test/expected/vector_agg_default.out index 930d105a2ed..49b629cd239 100644 --- a/tsl/test/expected/vector_agg_default.out +++ b/tsl/test/expected/vector_agg_default.out @@ -185,21 +185,17 @@ select sum(c) from dvagg having sum(c) > 0; -- Some negative cases. set timescaledb.debug_require_vector_agg to 'forbid'; explain (costs off) select sum(c) from dvagg group by grouping sets ((), (a)); - QUERY PLAN ----------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ MixedAggregate Hash Key: _hyper_1_1_chunk.a Group Key: () -> Append -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk - -> Sort - Sort Key: compress_hyper_2_2_chunk._ts_meta_min_1, compress_hyper_2_2_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_2_2_chunk + -> Index Scan Backward using compress_hyper_2_2_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_2_2_chunk -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk - -> Sort - Sort Key: compress_hyper_2_4_chunk._ts_meta_min_1, compress_hyper_2_4_chunk._ts_meta_max_1 - -> Seq Scan on compress_hyper_2_4_chunk -(12 rows) + -> Index Scan Backward using compress_hyper_2_4_chunk__ts_meta_min_1__ts_meta_max_1_idx on compress_hyper_2_4_chunk +(8 rows) -- As a reference, the result on decompressed table. select decompress_chunk(show_chunks('dvagg')); diff --git a/tsl/test/sql/recompress_chunk_segmentwise.sql b/tsl/test/sql/recompress_chunk_segmentwise.sql index 3c6a43ec9c0..eb567c8e654 100644 --- a/tsl/test/sql/recompress_chunk_segmentwise.sql +++ b/tsl/test/sql/recompress_chunk_segmentwise.sql @@ -235,6 +235,7 @@ RESET enable_seqscan; SELECT decompress_chunk(show_chunks('mytab')); alter table mytab set (timescaledb.compress = false); alter table mytab set (timescaledb.compress); +SET timescaledb.enable_segmentwise_recompression TO OFF; select compress_chunk(show_chunks('mytab')); select compressed_chunk_name as compressed_chunk_name_before_recompression from compressed_chunk_info_view where hypertable_name = 'mytab' \gset INSERT INTO mytab VALUES ('2023-01-01'::timestamptz, 2, 3, 2); @@ -242,6 +243,7 @@ INSERT INTO mytab VALUES ('2023-01-01'::timestamptz, 2, 3, 2); SELECT compress_chunk(:'chunk_to_compress_mytab'); select compressed_chunk_name as compressed_chunk_name_after_recompression from compressed_chunk_info_view where hypertable_name = 'mytab' \gset select :'compressed_chunk_name_before_recompression' as before_recompression, :'compressed_chunk_name_after_recompression' as after_recompression; +RESET timescaledb.enable_segmentwise_recompression; -- check behavior with NULL values in segmentby columns select '2022-01-01 09:00:00+00' as start_time \gset