From 5e9e4502ec526834fd62deb2c8d905b28c0c5c22 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Wed, 24 Jan 2024 22:35:52 +0100 Subject: [PATCH 01/12] Account for filters in DecompressChunk row estimates We don't account for them at all currently, which leads to weird planning behavior, like the filters not influencing the position of relations in join. --- tsl/src/nodes/decompress_chunk/decompress_chunk.c | 9 +++++---- tsl/src/nodes/decompress_chunk/qual_pushdown.c | 12 ++++++++++++ .../transparent_decompression_ordered_index-15.out | 9 ++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.c b/tsl/src/nodes/decompress_chunk/decompress_chunk.c index aedc982289d..57b61b17ca0 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.c +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.c @@ -321,7 +321,7 @@ build_compressioninfo(PlannerInfo *root, Hypertable *ht, RelOptInfo *chunk_rel) * we put cost of 1 tuple of compressed_scan as startup cost */ static void -cost_decompress_chunk(Path *path, Path *compressed_path) +cost_decompress_chunk(PlannerInfo *root, Path *path, Path *compressed_path) { /* startup_cost is cost before fetching first tuple */ if (compressed_path->rows > 0) @@ -329,7 +329,8 @@ cost_decompress_chunk(Path *path, Path *compressed_path) /* total_cost is cost for fetching all tuples */ path->total_cost = compressed_path->total_cost + path->rows * cpu_tuple_cost; - path->rows = compressed_path->rows * DECOMPRESS_CHUNK_BATCH_SIZE; + path->rows = compressed_path->rows * DECOMPRESS_CHUNK_BATCH_SIZE * + clauselist_selectivity(root, path->parent->baserestrictinfo, 0, JOIN_INNER, NULL); } /* Smoothstep function S1 (the h01 cubic Hermite spline). */ @@ -899,7 +900,7 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp work_mem, -1); - cost_decompress_chunk(&dcpath->custom_path.path, &sort_path); + cost_decompress_chunk(root, &dcpath->custom_path.path, &sort_path); } /* * if chunk is partially compressed don't add this now but add an append path later @@ -1749,7 +1750,7 @@ decompress_chunk_path_create(PlannerInfo *root, CompressionInfo *info, int paral path->custom_path.custom_paths = list_make1(compressed_path); path->reverse = false; path->compressed_pathkeys = NIL; - cost_decompress_chunk(&path->custom_path.path, compressed_path); + cost_decompress_chunk(root, &path->custom_path.path, compressed_path); return path; } diff --git a/tsl/src/nodes/decompress_chunk/qual_pushdown.c b/tsl/src/nodes/decompress_chunk/qual_pushdown.c index 6fd9ff9b516..8044813a800 100644 --- a/tsl/src/nodes/decompress_chunk/qual_pushdown.c +++ b/tsl/src/nodes/decompress_chunk/qual_pushdown.c @@ -87,6 +87,18 @@ pushdown_quals(PlannerInfo *root, CompressionSettings *settings, RelOptInfo *chu { decompress_clauses = lappend(decompress_clauses, ri); } + + if (context.needs_recheck) + { + /* + * If we managed to push down the comparison of orderby column + * to the compressed scan, most matched batches are likely to + * match entirely, so the selectivity of the recheck will be + * close to 1. + */ + ri->norm_selec = 1; + Assert(context.can_pushdown); + } } chunk_rel->baserestrictinfo = decompress_clauses; } diff --git a/tsl/test/expected/transparent_decompression_ordered_index-15.out b/tsl/test/expected/transparent_decompression_ordered_index-15.out index 703add3c7cb..865743de502 100644 --- a/tsl/test/expected/transparent_decompression_ordered_index-15.out +++ b/tsl/test/expected/transparent_decompression_ordered_index-15.out @@ -701,20 +701,19 @@ ON met.device_id = q.node and met.device_id_peer = q.device_id_peer QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (actual rows=1 loops=1) - Join Filter: (nodetime.node = met.device_id) + Join Filter: (("*VALUES*".column2 = met.device_id_peer) AND ("*VALUES*".column3 = met.v0)) -> Nested Loop (actual rows=1 loops=1) Join Filter: (nodetime.node = "*VALUES*".column1) Rows Removed by Join Filter: 1 -> Seq Scan on nodetime (actual rows=1 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_4_chunk met (actual rows=1 loops=1) - Filter: ("*VALUES*".column3 = v0) - Rows Removed by Filter: 47 Vectorized Filter: ((v0 > 2) AND ("time" = 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) + Rows Removed by Filter: 47 -> Index Scan using compress_hyper_2_9_chunk_device_id_device_id_peer__ts_meta__idx on compress_hyper_2_9_chunk (actual rows=1 loops=1) - Index Cond: ((device_id = "*VALUES*".column1) AND (device_id_peer = "*VALUES*".column2)) + Index Cond: (device_id = nodetime.node) Filter: ((_ts_meta_min_1 <= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone) AND (_ts_meta_max_1 >= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) -(14 rows) +(13 rows) -- filter on compressed attr (v0) with seqscan enabled and indexscan -- disabled. filters on compressed attr should be above the seq scan. From ee4147f14d5cdac261d401f58300d7d7f9f7e3b0 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:08:14 +0100 Subject: [PATCH 02/12] refs --- tsl/test/expected/vectorized_aggregation.out | 246 +++++++++--------- .../transparent_decompress_chunk-15.out | 94 +++---- 2 files changed, 158 insertions(+), 182 deletions(-) diff --git a/tsl/test/expected/vectorized_aggregation.out b/tsl/test/expected/vectorized_aggregation.out index e3a4bb4cf18..92d9a819bb4 100644 --- a/tsl/test/expected/vectorized_aggregation.out +++ b/tsl/test/expected/vectorized_aggregation.out @@ -232,139 +232,133 @@ SELECT sum(segment_by_value) FROM testtable WHERE segment_by_value > 0 AND int_v :EXPLAIN SELECT sum(segment_by_value) FROM testtable WHERE int_value > 0; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Finalize Aggregate Output: sum(_hyper_1_1_chunk.segment_by_value) - -> Gather - Output: (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) - Workers Planned: 2 - -> Parallel Append - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_1_chunk.segment_by_value) - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk - Output: _hyper_1_1_chunk.segment_by_value - Vectorized Filter: (_hyper_1_1_chunk.int_value > 0) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk - Output: compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value, compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk._ts_meta_sequence_num, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1 - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_2_chunk.segment_by_value) - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk - Output: _hyper_1_2_chunk.segment_by_value - Vectorized Filter: (_hyper_1_2_chunk.int_value > 0) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk - Output: compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value, compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk._ts_meta_sequence_num, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1 - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_3_chunk.segment_by_value) - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk - Output: _hyper_1_3_chunk.segment_by_value - Vectorized Filter: (_hyper_1_3_chunk.int_value > 0) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk - Output: compress_hyper_2_13_chunk."time", compress_hyper_2_13_chunk.segment_by_value, compress_hyper_2_13_chunk.int_value, compress_hyper_2_13_chunk.float_value, compress_hyper_2_13_chunk._ts_meta_count, compress_hyper_2_13_chunk._ts_meta_sequence_num, compress_hyper_2_13_chunk._ts_meta_min_1, compress_hyper_2_13_chunk._ts_meta_max_1 - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_4_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_4_chunk - Output: _hyper_1_4_chunk.segment_by_value - Filter: (_hyper_1_4_chunk.int_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_5_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_5_chunk - Output: _hyper_1_5_chunk.segment_by_value - Filter: (_hyper_1_5_chunk.int_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_6_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_6_chunk - Output: _hyper_1_6_chunk.segment_by_value - Filter: (_hyper_1_6_chunk.int_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_7_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_7_chunk - Output: _hyper_1_7_chunk.segment_by_value - Filter: (_hyper_1_7_chunk.int_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_8_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_8_chunk - Output: _hyper_1_8_chunk.segment_by_value - Filter: (_hyper_1_8_chunk.int_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_9_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_9_chunk - Output: _hyper_1_9_chunk.segment_by_value - Filter: (_hyper_1_9_chunk.int_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_10_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_10_chunk - Output: _hyper_1_10_chunk.segment_by_value - Filter: (_hyper_1_10_chunk.int_value > 0) -(62 rows) + -> Append + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_1_chunk.segment_by_value) + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk + Output: _hyper_1_1_chunk.segment_by_value + Vectorized Filter: (_hyper_1_1_chunk.int_value > 0) + -> Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk + Output: compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value, compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk._ts_meta_sequence_num, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1 + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_2_chunk.segment_by_value) + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk + Output: _hyper_1_2_chunk.segment_by_value + Vectorized Filter: (_hyper_1_2_chunk.int_value > 0) + -> Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk + Output: compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value, compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk._ts_meta_sequence_num, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1 + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_3_chunk.segment_by_value) + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk + Output: _hyper_1_3_chunk.segment_by_value + Vectorized Filter: (_hyper_1_3_chunk.int_value > 0) + -> Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk + Output: compress_hyper_2_13_chunk."time", compress_hyper_2_13_chunk.segment_by_value, compress_hyper_2_13_chunk.int_value, compress_hyper_2_13_chunk.float_value, compress_hyper_2_13_chunk._ts_meta_count, compress_hyper_2_13_chunk._ts_meta_sequence_num, compress_hyper_2_13_chunk._ts_meta_min_1, compress_hyper_2_13_chunk._ts_meta_max_1 + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_4_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_4_chunk + Output: _hyper_1_4_chunk.segment_by_value + Filter: (_hyper_1_4_chunk.int_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_5_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_5_chunk + Output: _hyper_1_5_chunk.segment_by_value + Filter: (_hyper_1_5_chunk.int_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_6_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_6_chunk + Output: _hyper_1_6_chunk.segment_by_value + Filter: (_hyper_1_6_chunk.int_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_7_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_7_chunk + Output: _hyper_1_7_chunk.segment_by_value + Filter: (_hyper_1_7_chunk.int_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_8_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_8_chunk + Output: _hyper_1_8_chunk.segment_by_value + Filter: (_hyper_1_8_chunk.int_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_9_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_9_chunk + Output: _hyper_1_9_chunk.segment_by_value + Filter: (_hyper_1_9_chunk.int_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_10_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_10_chunk + Output: _hyper_1_10_chunk.segment_by_value + Filter: (_hyper_1_10_chunk.int_value > 0) +(59 rows) :EXPLAIN SELECT sum(segment_by_value) FROM testtable WHERE float_value > 0; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Finalize Aggregate Output: sum(_hyper_1_1_chunk.segment_by_value) - -> Gather - Output: (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) - Workers Planned: 2 - -> Parallel Append - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_1_chunk.segment_by_value) - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk - Output: _hyper_1_1_chunk.segment_by_value - Vectorized Filter: (_hyper_1_1_chunk.float_value > '0'::double precision) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk - Output: compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value, compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk._ts_meta_sequence_num, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1 - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_2_chunk.segment_by_value) - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk - Output: _hyper_1_2_chunk.segment_by_value - Vectorized Filter: (_hyper_1_2_chunk.float_value > '0'::double precision) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk - Output: compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value, compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk._ts_meta_sequence_num, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1 - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_3_chunk.segment_by_value) - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk - Output: _hyper_1_3_chunk.segment_by_value - Vectorized Filter: (_hyper_1_3_chunk.float_value > '0'::double precision) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk - Output: compress_hyper_2_13_chunk."time", compress_hyper_2_13_chunk.segment_by_value, compress_hyper_2_13_chunk.int_value, compress_hyper_2_13_chunk.float_value, compress_hyper_2_13_chunk._ts_meta_count, compress_hyper_2_13_chunk._ts_meta_sequence_num, compress_hyper_2_13_chunk._ts_meta_min_1, compress_hyper_2_13_chunk._ts_meta_max_1 - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_4_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_4_chunk - Output: _hyper_1_4_chunk.segment_by_value - Filter: (_hyper_1_4_chunk.float_value > '0'::double precision) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_5_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_5_chunk - Output: _hyper_1_5_chunk.segment_by_value - Filter: (_hyper_1_5_chunk.float_value > '0'::double precision) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_6_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_6_chunk - Output: _hyper_1_6_chunk.segment_by_value - Filter: (_hyper_1_6_chunk.float_value > '0'::double precision) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_7_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_7_chunk - Output: _hyper_1_7_chunk.segment_by_value - Filter: (_hyper_1_7_chunk.float_value > '0'::double precision) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_8_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_8_chunk - Output: _hyper_1_8_chunk.segment_by_value - Filter: (_hyper_1_8_chunk.float_value > '0'::double precision) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_9_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_9_chunk - Output: _hyper_1_9_chunk.segment_by_value - Filter: (_hyper_1_9_chunk.float_value > '0'::double precision) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_10_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_10_chunk - Output: _hyper_1_10_chunk.segment_by_value - Filter: (_hyper_1_10_chunk.float_value > '0'::double precision) -(62 rows) + -> Append + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_1_chunk.segment_by_value) + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk + Output: _hyper_1_1_chunk.segment_by_value + Vectorized Filter: (_hyper_1_1_chunk.float_value > '0'::double precision) + -> Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk + Output: compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value, compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk._ts_meta_sequence_num, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1 + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_2_chunk.segment_by_value) + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk + Output: _hyper_1_2_chunk.segment_by_value + Vectorized Filter: (_hyper_1_2_chunk.float_value > '0'::double precision) + -> Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk + Output: compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value, compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk._ts_meta_sequence_num, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1 + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_3_chunk.segment_by_value) + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk + Output: _hyper_1_3_chunk.segment_by_value + Vectorized Filter: (_hyper_1_3_chunk.float_value > '0'::double precision) + -> Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk + Output: compress_hyper_2_13_chunk."time", compress_hyper_2_13_chunk.segment_by_value, compress_hyper_2_13_chunk.int_value, compress_hyper_2_13_chunk.float_value, compress_hyper_2_13_chunk._ts_meta_count, compress_hyper_2_13_chunk._ts_meta_sequence_num, compress_hyper_2_13_chunk._ts_meta_min_1, compress_hyper_2_13_chunk._ts_meta_max_1 + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_4_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_4_chunk + Output: _hyper_1_4_chunk.segment_by_value + Filter: (_hyper_1_4_chunk.float_value > '0'::double precision) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_5_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_5_chunk + Output: _hyper_1_5_chunk.segment_by_value + Filter: (_hyper_1_5_chunk.float_value > '0'::double precision) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_6_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_6_chunk + Output: _hyper_1_6_chunk.segment_by_value + Filter: (_hyper_1_6_chunk.float_value > '0'::double precision) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_7_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_7_chunk + Output: _hyper_1_7_chunk.segment_by_value + Filter: (_hyper_1_7_chunk.float_value > '0'::double precision) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_8_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_8_chunk + Output: _hyper_1_8_chunk.segment_by_value + Filter: (_hyper_1_8_chunk.float_value > '0'::double precision) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_9_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_9_chunk + Output: _hyper_1_9_chunk.segment_by_value + Filter: (_hyper_1_9_chunk.float_value > '0'::double precision) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_10_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_10_chunk + Output: _hyper_1_10_chunk.segment_by_value + Filter: (_hyper_1_10_chunk.float_value > '0'::double precision) +(59 rows) -- Vectorization not possible due grouping :EXPLAIN diff --git a/tsl/test/shared/expected/transparent_decompress_chunk-15.out b/tsl/test/shared/expected/transparent_decompress_chunk-15.out index 6167c6c8ec7..338b4c2e82d 100644 --- a/tsl/test/shared/expected/transparent_decompress_chunk-15.out +++ b/tsl/test/shared/expected/transparent_decompress_chunk-15.out @@ -187,18 +187,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id = v0 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (device_id = v0) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (device_id = v0) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id < v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -229,14 +225,12 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id = length(substring(version(), 1, 3)) ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id = length("substring"(version(), 1, 3))) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id = length("substring"(version(), 1, 3))) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test segment meta pushdown -- order by column and const @@ -318,18 +312,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < 1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Vectorized Filter: (v0 < 1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Vectorized Filter: (v0 < 1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -365,35 +355,27 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v1 = device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v1 = device_id) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v1 = device_id) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown between two order by column (not pushed down) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 = v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v0 = v1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v0 = v1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown of quals on order by and segment by cols anded together :PREFIX_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' AND device_id = 1 ORDER BY time, device_id LIMIT 10; From b710c3eeb245e722b6cf59f85235e40710d5cfea Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:21:23 +0100 Subject: [PATCH 03/12] stable mapc test --- .../merge_append_partially_compressed-15.out | 925 ++++++++---------- .../merge_append_partially_compressed.sql.in | 59 +- 2 files changed, 451 insertions(+), 533 deletions(-) diff --git a/tsl/test/expected/merge_append_partially_compressed-15.out b/tsl/test/expected/merge_append_partially_compressed-15.out index ee9f92d7eeb..8df038e4453 100644 --- a/tsl/test/expected/merge_append_partially_compressed-15.out +++ b/tsl/test/expected/merge_append_partially_compressed-15.out @@ -7,72 +7,77 @@ set enable_parallel_append to off; -- for less flaky plans set timescaledb.enable_decompression_sorted_merge = off; \set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)' -CREATE TABLE ht_metrics_compressed(time timestamptz, device int, value float); -SELECT create_hypertable('ht_metrics_compressed','time'); +CREATE TABLE mapc_test(time timestamptz, device int, value float); +SELECT create_hypertable('mapc_test','time', create_default_indexes => false); NOTICE: adding not-null constraint to column "time" - create_hypertable ------------------------------------- - (1,public,ht_metrics_compressed,t) + create_hypertable +------------------------ + (1,public,mapc_test,t) (1 row) -ALTER TABLE ht_metrics_compressed SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); -INSERT INTO ht_metrics_compressed +ALTER TABLE mapc_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'6 hour') time, -generate_series(1,3) device; -SELECT compress_chunk(c) FROM show_chunks('ht_metrics_compressed') c; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 second') time, +generate_series(1,10) device; +select format('select count(*), min(time) from %s', x) from show_chunks('mapc_test') x \gexec +select count(*), min(time) from _timescaledb_internal._hyper_1_1_chunk + count | min +---------+------------------------------ + 1440000 | Thu Jan 02 00:00:00 2020 PST +(1 row) + +select count(*), min(time) from _timescaledb_internal._hyper_1_2_chunk + count | min +---------+------------------------------ + 1368010 | Wed Jan 08 16:00:00 2020 PST +(1 row) + +SELECT compress_chunk(c) FROM show_chunks('mapc_test') c; compress_chunk ---------------------------------------- _timescaledb_internal._hyper_1_1_chunk _timescaledb_internal._hyper_1_2_chunk - _timescaledb_internal._hyper_1_3_chunk -(3 rows) +(2 rows) -- make them partially compressed -INSERT INTO ht_metrics_compressed +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'9 hour') time, -generate_series(1,3) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 minute') time, +generate_series(1,10) device; +create index on mapc_test(time); +analyze mapc_test; -- chunkAppend eligible queries (from tsbench) -- sort is not pushed down -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time DESC, device LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time DESC, device LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC, ht_metrics_compressed.device + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC, mapc_test.device -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -81,252 +86,192 @@ generate_series(1,3) device; -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Result (actual rows=81 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Result (actual rows=1440000 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1440000 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Result (actual rows=84 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=84 loops=1) - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Result (actual rows=1368010 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Result (actual rows=30 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(33 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time desc limit 10; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time desc limit 10; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=10 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=10 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=10 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Sort (actual rows=7 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: quicksort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) + -> Sort (actual rows=10 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) + Sort Method: top-N heapsort + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('2d',time) DESC LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('2d',time) DESC LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: time_bucket('@ 2 days'::interval, ht_metrics_compressed."time") DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: time_bucket('@ 2 days'::interval, mapc_test."time") DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC Sort Method: top-N heapsort - -> Result (actual rows=30 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Result (actual rows=1368010 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Sort (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Result (never executed) - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Result (never executed) -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(35 rows) +(25 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=410403 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 15967 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time", ht_metrics_compressed.device DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time", mapc_test.device DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=432000 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -- index scan, no sort on top -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -- index scan, no resorting required +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) - -> Sort (never executed) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) + Rows Removed by Filter: 20529 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -- this uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -334,90 +279,71 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=19 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) - Rows Removed by Filter: 38 - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 -(33 rows) + Rows Removed by Filter: 20529 +(23 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- this also uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = 3) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = 3) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; time | device | value ------------------------------+--------+------- Thu Jan 02 00:00:00 2020 PST | 3 | 0.3 (1 row) -- not eligible for chunkAppend, but eligible for sort pushdown -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM mapc_test ORDER BY device, time DESC LIMIT 1; -- with pushdown QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -425,76 +351,57 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(30 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(21 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -(39 rows) + Rows Removed by Filter: 15967 +(29 rows) CREATE TABLE test1 ( time timestamptz NOT NULL, @@ -515,7 +422,7 @@ INSERT INTO test1 (time, x1, x2, x3, x4, x5) values('2000-01-01 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test1') i; compress_chunk ---------------------------------------- - _timescaledb_internal._hyper_3_7_chunk + _timescaledb_internal._hyper_3_5_chunk (1 row) ANALYZE test1; @@ -530,16 +437,16 @@ SELECT * FROM test1 ORDER BY time DESC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -550,16 +457,16 @@ SELECT * FROM test1 ORDER BY time DESC LIMIT 10; -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (14 rows) -- requires resorting @@ -570,16 +477,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) -- all these require resorting, no pushdown can happen @@ -590,16 +497,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 ASC NU Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -609,16 +516,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -628,16 +535,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -647,16 +554,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -666,16 +573,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -685,16 +592,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS FIRST, x3 DESC NULLS LAST, x4 ASC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" NULLS FIRST, test1.x3 DESC NULLS LAST, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) set max_parallel_workers_per_gather = 0; -- parallel plan different on Windows @@ -709,16 +616,16 @@ SELECT x1, x2, max(time) FROM test1 GROUP BY x1, x2, time ORDER BY time limit 10 -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x1, test1.x2 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (16 rows) reset max_parallel_workers_per_gather; @@ -729,16 +636,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, x4, time LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -747,16 +654,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -765,16 +672,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -783,16 +690,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3, x4 LIMIT 10; ---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -801,16 +708,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 DESC LIMIT 10; -- no pushdown ------------------------------------------------------------------------------------------------------------------------------------------ Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) -- queries with pushdown @@ -820,16 +727,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -838,16 +745,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time DESC, x3 ASC, x4 ASC LIMIT 10; -- --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -856,16 +763,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time ASC, x3 DESC, x4 DESC LIMIT 10; -- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -874,16 +781,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 DESC LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) --------------------------------------------------------------------------- @@ -911,10 +818,10 @@ INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 01:00:00-00', 1, INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 02:00:00-00', 2, 1, 3, 3, 0); INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, 2, 4, 4, 0); SELECT compress_chunk(i) FROM show_chunks('test2') i; - compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_5_9_chunk - _timescaledb_internal._hyper_5_10_chunk + compress_chunk +---------------------------------------- + _timescaledb_internal._hyper_5_7_chunk + _timescaledb_internal._hyper_5_8_chunk (2 rows) -- make them partially compressed @@ -926,25 +833,25 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3; @@ -966,25 +873,25 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; @@ -1004,28 +911,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; -- queries where sort is not pushed down :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x3; - QUERY PLAN ----------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x3; @@ -1044,28 +951,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x3; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, x4; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------ Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x4; @@ -1084,28 +991,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x4; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, time; @@ -1156,10 +1063,10 @@ INSERT INTO test3 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test3') i; compress_chunk ----------------------------------------- + _timescaledb_internal._hyper_7_11_chunk + _timescaledb_internal._hyper_7_12_chunk _timescaledb_internal._hyper_7_13_chunk _timescaledb_internal._hyper_7_14_chunk - _timescaledb_internal._hyper_7_15_chunk - _timescaledb_internal._hyper_7_16_chunk (4 rows) -- make them partially compressed @@ -1171,7 +1078,21 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1186,20 +1107,6 @@ set enable_indexscan = off; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3; @@ -1221,7 +1128,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1236,20 +1157,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; @@ -1272,7 +1179,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; QUERY PLAN ---------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 Sort Method: quicksort @@ -1287,20 +1208,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x3; @@ -1322,7 +1229,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; QUERY PLAN ---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 Sort Method: quicksort @@ -1337,20 +1258,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x4; @@ -1372,7 +1279,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" Sort Method: quicksort @@ -1387,20 +1308,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, time; diff --git a/tsl/test/sql/merge_append_partially_compressed.sql.in b/tsl/test/sql/merge_append_partially_compressed.sql.in index c20535a990a..068dd4a954a 100644 --- a/tsl/test/sql/merge_append_partially_compressed.sql.in +++ b/tsl/test/sql/merge_append_partially_compressed.sql.in @@ -11,41 +11,52 @@ set enable_parallel_append to off; -- for less flaky plans set timescaledb.enable_decompression_sorted_merge = off; \set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)' -CREATE TABLE ht_metrics_compressed(time timestamptz, device int, value float); -SELECT create_hypertable('ht_metrics_compressed','time'); -ALTER TABLE ht_metrics_compressed SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); +CREATE TABLE mapc_test(time timestamptz, device int, value float); +SELECT create_hypertable('mapc_test','time', create_default_indexes => false); +ALTER TABLE mapc_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); -INSERT INTO ht_metrics_compressed +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'6 hour') time, -generate_series(1,3) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 second') time, +generate_series(1,10) device; -SELECT compress_chunk(c) FROM show_chunks('ht_metrics_compressed') c; +select format('select count(*), min(time) from %s', x) from show_chunks('mapc_test') x \gexec + +SELECT compress_chunk(c) FROM show_chunks('mapc_test') c; -- make them partially compressed -INSERT INTO ht_metrics_compressed +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'9 hour') time, -generate_series(1,3) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 minute') time, +generate_series(1,10) device; + +create index on mapc_test(time); + +analyze mapc_test; -- chunkAppend eligible queries (from tsbench) -- sort is not pushed down -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time DESC, device LIMIT 1; -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time desc limit 10; -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('2d',time) DESC LIMIT 1; -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time DESC, device LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time desc limit 10; +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('2d',time) DESC LIMIT 1; +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; + +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; + +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; + -- index scan, no sort on top -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -- index scan, no resorting required -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -- this uses the index and does not do sort on top -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- this also uses the index and does not do sort on top -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- not eligible for chunkAppend, but eligible for sort pushdown -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY device, time DESC LIMIT 1; -- with pushdown -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM mapc_test ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown CREATE TABLE test1 ( time timestamptz NOT NULL, From 87101d20d3887ac8aea082a4332b8eb0b5bc8029 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 25 Jan 2024 01:24:16 +0100 Subject: [PATCH 04/12] reference transparent_decompression_ordered_index-* merge_append_partially_compressed-* --- .../merge_append_partially_compressed-16.out | 925 ++++++++---------- ...sparent_decompression_ordered_index-16.out | 9 +- 2 files changed, 420 insertions(+), 514 deletions(-) diff --git a/tsl/test/expected/merge_append_partially_compressed-16.out b/tsl/test/expected/merge_append_partially_compressed-16.out index ee9f92d7eeb..8df038e4453 100644 --- a/tsl/test/expected/merge_append_partially_compressed-16.out +++ b/tsl/test/expected/merge_append_partially_compressed-16.out @@ -7,72 +7,77 @@ set enable_parallel_append to off; -- for less flaky plans set timescaledb.enable_decompression_sorted_merge = off; \set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)' -CREATE TABLE ht_metrics_compressed(time timestamptz, device int, value float); -SELECT create_hypertable('ht_metrics_compressed','time'); +CREATE TABLE mapc_test(time timestamptz, device int, value float); +SELECT create_hypertable('mapc_test','time', create_default_indexes => false); NOTICE: adding not-null constraint to column "time" - create_hypertable ------------------------------------- - (1,public,ht_metrics_compressed,t) + create_hypertable +------------------------ + (1,public,mapc_test,t) (1 row) -ALTER TABLE ht_metrics_compressed SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); -INSERT INTO ht_metrics_compressed +ALTER TABLE mapc_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'6 hour') time, -generate_series(1,3) device; -SELECT compress_chunk(c) FROM show_chunks('ht_metrics_compressed') c; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 second') time, +generate_series(1,10) device; +select format('select count(*), min(time) from %s', x) from show_chunks('mapc_test') x \gexec +select count(*), min(time) from _timescaledb_internal._hyper_1_1_chunk + count | min +---------+------------------------------ + 1440000 | Thu Jan 02 00:00:00 2020 PST +(1 row) + +select count(*), min(time) from _timescaledb_internal._hyper_1_2_chunk + count | min +---------+------------------------------ + 1368010 | Wed Jan 08 16:00:00 2020 PST +(1 row) + +SELECT compress_chunk(c) FROM show_chunks('mapc_test') c; compress_chunk ---------------------------------------- _timescaledb_internal._hyper_1_1_chunk _timescaledb_internal._hyper_1_2_chunk - _timescaledb_internal._hyper_1_3_chunk -(3 rows) +(2 rows) -- make them partially compressed -INSERT INTO ht_metrics_compressed +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'9 hour') time, -generate_series(1,3) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 minute') time, +generate_series(1,10) device; +create index on mapc_test(time); +analyze mapc_test; -- chunkAppend eligible queries (from tsbench) -- sort is not pushed down -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time DESC, device LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time DESC, device LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC, ht_metrics_compressed.device + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC, mapc_test.device -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -81,252 +86,192 @@ generate_series(1,3) device; -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Result (actual rows=81 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Result (actual rows=1440000 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1440000 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Result (actual rows=84 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=84 loops=1) - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Result (actual rows=1368010 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Result (actual rows=30 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(33 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time desc limit 10; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time desc limit 10; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=10 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=10 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=10 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Sort (actual rows=7 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: quicksort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) + -> Sort (actual rows=10 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) + Sort Method: top-N heapsort + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('2d',time) DESC LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('2d',time) DESC LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: time_bucket('@ 2 days'::interval, ht_metrics_compressed."time") DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: time_bucket('@ 2 days'::interval, mapc_test."time") DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC Sort Method: top-N heapsort - -> Result (actual rows=30 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Result (actual rows=1368010 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Sort (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Result (never executed) - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Result (never executed) -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(35 rows) +(25 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=410403 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 15967 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time", ht_metrics_compressed.device DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time", mapc_test.device DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=432000 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -- index scan, no sort on top -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -- index scan, no resorting required +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) - -> Sort (never executed) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) + Rows Removed by Filter: 20529 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -- this uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -334,90 +279,71 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=19 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) - Rows Removed by Filter: 38 - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 -(33 rows) + Rows Removed by Filter: 20529 +(23 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- this also uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = 3) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = 3) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; time | device | value ------------------------------+--------+------- Thu Jan 02 00:00:00 2020 PST | 3 | 0.3 (1 row) -- not eligible for chunkAppend, but eligible for sort pushdown -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM mapc_test ORDER BY device, time DESC LIMIT 1; -- with pushdown QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -425,76 +351,57 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(30 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(21 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -(39 rows) + Rows Removed by Filter: 15967 +(29 rows) CREATE TABLE test1 ( time timestamptz NOT NULL, @@ -515,7 +422,7 @@ INSERT INTO test1 (time, x1, x2, x3, x4, x5) values('2000-01-01 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test1') i; compress_chunk ---------------------------------------- - _timescaledb_internal._hyper_3_7_chunk + _timescaledb_internal._hyper_3_5_chunk (1 row) ANALYZE test1; @@ -530,16 +437,16 @@ SELECT * FROM test1 ORDER BY time DESC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -550,16 +457,16 @@ SELECT * FROM test1 ORDER BY time DESC LIMIT 10; -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (14 rows) -- requires resorting @@ -570,16 +477,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) -- all these require resorting, no pushdown can happen @@ -590,16 +497,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 ASC NU Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -609,16 +516,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -628,16 +535,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -647,16 +554,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -666,16 +573,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -685,16 +592,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS FIRST, x3 DESC NULLS LAST, x4 ASC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" NULLS FIRST, test1.x3 DESC NULLS LAST, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) set max_parallel_workers_per_gather = 0; -- parallel plan different on Windows @@ -709,16 +616,16 @@ SELECT x1, x2, max(time) FROM test1 GROUP BY x1, x2, time ORDER BY time limit 10 -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x1, test1.x2 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (16 rows) reset max_parallel_workers_per_gather; @@ -729,16 +636,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, x4, time LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -747,16 +654,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -765,16 +672,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -783,16 +690,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3, x4 LIMIT 10; ---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -801,16 +708,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 DESC LIMIT 10; -- no pushdown ------------------------------------------------------------------------------------------------------------------------------------------ Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) -- queries with pushdown @@ -820,16 +727,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -838,16 +745,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time DESC, x3 ASC, x4 ASC LIMIT 10; -- --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -856,16 +763,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time ASC, x3 DESC, x4 DESC LIMIT 10; -- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -874,16 +781,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 DESC LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) --------------------------------------------------------------------------- @@ -911,10 +818,10 @@ INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 01:00:00-00', 1, INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 02:00:00-00', 2, 1, 3, 3, 0); INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, 2, 4, 4, 0); SELECT compress_chunk(i) FROM show_chunks('test2') i; - compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_5_9_chunk - _timescaledb_internal._hyper_5_10_chunk + compress_chunk +---------------------------------------- + _timescaledb_internal._hyper_5_7_chunk + _timescaledb_internal._hyper_5_8_chunk (2 rows) -- make them partially compressed @@ -926,25 +833,25 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3; @@ -966,25 +873,25 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; @@ -1004,28 +911,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; -- queries where sort is not pushed down :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x3; - QUERY PLAN ----------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x3; @@ -1044,28 +951,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x3; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, x4; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------ Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x4; @@ -1084,28 +991,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x4; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, time; @@ -1156,10 +1063,10 @@ INSERT INTO test3 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test3') i; compress_chunk ----------------------------------------- + _timescaledb_internal._hyper_7_11_chunk + _timescaledb_internal._hyper_7_12_chunk _timescaledb_internal._hyper_7_13_chunk _timescaledb_internal._hyper_7_14_chunk - _timescaledb_internal._hyper_7_15_chunk - _timescaledb_internal._hyper_7_16_chunk (4 rows) -- make them partially compressed @@ -1171,7 +1078,21 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1186,20 +1107,6 @@ set enable_indexscan = off; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3; @@ -1221,7 +1128,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1236,20 +1157,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; @@ -1272,7 +1179,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; QUERY PLAN ---------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 Sort Method: quicksort @@ -1287,20 +1208,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x3; @@ -1322,7 +1229,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; QUERY PLAN ---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 Sort Method: quicksort @@ -1337,20 +1258,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x4; @@ -1372,7 +1279,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" Sort Method: quicksort @@ -1387,20 +1308,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, time; diff --git a/tsl/test/expected/transparent_decompression_ordered_index-16.out b/tsl/test/expected/transparent_decompression_ordered_index-16.out index 2aa9cd4ad00..7edd09380ae 100644 --- a/tsl/test/expected/transparent_decompression_ordered_index-16.out +++ b/tsl/test/expected/transparent_decompression_ordered_index-16.out @@ -701,20 +701,19 @@ ON met.device_id = q.node and met.device_id_peer = q.device_id_peer QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (actual rows=1 loops=1) - Join Filter: (met.device_id = nodetime.node) + Join Filter: ((met.device_id_peer = "*VALUES*".column2) AND ("*VALUES*".column3 = met.v0)) -> Nested Loop (actual rows=1 loops=1) Join Filter: (nodetime.node = "*VALUES*".column1) Rows Removed by Join Filter: 1 -> Seq Scan on nodetime (actual rows=1 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_4_chunk met (actual rows=1 loops=1) - Filter: ("*VALUES*".column3 = v0) - Rows Removed by Filter: 47 Vectorized Filter: ((v0 > 2) AND ("time" = 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) + Rows Removed by Filter: 47 -> Index Scan using compress_hyper_2_9_chunk_device_id_device_id_peer__ts_meta__idx on compress_hyper_2_9_chunk (actual rows=1 loops=1) - Index Cond: ((device_id = "*VALUES*".column1) AND (device_id_peer = "*VALUES*".column2)) + Index Cond: (device_id = nodetime.node) Filter: ((_ts_meta_min_1 <= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone) AND (_ts_meta_max_1 >= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) -(14 rows) +(13 rows) -- filter on compressed attr (v0) with seqscan enabled and indexscan -- disabled. filters on compressed attr should be above the seq scan. From c744dfdbcf8ae1820717edcfa923303b132b6d53 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 25 Jan 2024 01:25:07 +0100 Subject: [PATCH 05/12] reference transparent_decompression_ordered_index-* merge_append_partially_compressed-* --- .../merge_append_partially_compressed-14.out | 917 ++++++++---------- ...sparent_decompression_ordered_index-14.out | 9 +- 2 files changed, 417 insertions(+), 509 deletions(-) diff --git a/tsl/test/expected/merge_append_partially_compressed-14.out b/tsl/test/expected/merge_append_partially_compressed-14.out index 77381c54acd..010e8d1728e 100644 --- a/tsl/test/expected/merge_append_partially_compressed-14.out +++ b/tsl/test/expected/merge_append_partially_compressed-14.out @@ -7,72 +7,77 @@ set enable_parallel_append to off; -- for less flaky plans set timescaledb.enable_decompression_sorted_merge = off; \set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)' -CREATE TABLE ht_metrics_compressed(time timestamptz, device int, value float); -SELECT create_hypertable('ht_metrics_compressed','time'); +CREATE TABLE mapc_test(time timestamptz, device int, value float); +SELECT create_hypertable('mapc_test','time', create_default_indexes => false); NOTICE: adding not-null constraint to column "time" - create_hypertable ------------------------------------- - (1,public,ht_metrics_compressed,t) + create_hypertable +------------------------ + (1,public,mapc_test,t) (1 row) -ALTER TABLE ht_metrics_compressed SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); -INSERT INTO ht_metrics_compressed +ALTER TABLE mapc_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'6 hour') time, -generate_series(1,3) device; -SELECT compress_chunk(c) FROM show_chunks('ht_metrics_compressed') c; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 second') time, +generate_series(1,10) device; +select format('select count(*), min(time) from %s', x) from show_chunks('mapc_test') x \gexec +select count(*), min(time) from _timescaledb_internal._hyper_1_1_chunk + count | min +---------+------------------------------ + 1440000 | Thu Jan 02 00:00:00 2020 PST +(1 row) + +select count(*), min(time) from _timescaledb_internal._hyper_1_2_chunk + count | min +---------+------------------------------ + 1368010 | Wed Jan 08 16:00:00 2020 PST +(1 row) + +SELECT compress_chunk(c) FROM show_chunks('mapc_test') c; compress_chunk ---------------------------------------- _timescaledb_internal._hyper_1_1_chunk _timescaledb_internal._hyper_1_2_chunk - _timescaledb_internal._hyper_1_3_chunk -(3 rows) +(2 rows) -- make them partially compressed -INSERT INTO ht_metrics_compressed +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'9 hour') time, -generate_series(1,3) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 minute') time, +generate_series(1,10) device; +create index on mapc_test(time); +analyze mapc_test; -- chunkAppend eligible queries (from tsbench) -- sort is not pushed down -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time DESC, device LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time DESC, device LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC, ht_metrics_compressed.device + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC, mapc_test.device -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -81,246 +86,188 @@ generate_series(1,3) device; -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1440000 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=84 loops=1) - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(30 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(21 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time desc limit 10; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time desc limit 10; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=10 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=10 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=10 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Sort (actual rows=7 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: quicksort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) + -> Sort (actual rows=10 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) + Sort Method: top-N heapsort + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('2d',time) DESC LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('2d',time) DESC LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: time_bucket('@ 2 days'::interval, ht_metrics_compressed."time") DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: time_bucket('@ 2 days'::interval, mapc_test."time") DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Sort (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=410403 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 15967 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time", ht_metrics_compressed.device DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time", mapc_test.device DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=432000 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -- index scan, no sort on top -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -- index scan, no resorting required +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) - -> Sort (never executed) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) + Rows Removed by Filter: 20529 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -- this uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -328,90 +275,71 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=19 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) - Rows Removed by Filter: 38 - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 -(33 rows) + Rows Removed by Filter: 20529 +(23 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- this also uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = 3) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = 3) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; time | device | value ------------------------------+--------+------- Thu Jan 02 00:00:00 2020 PST | 3 | 0.3 (1 row) -- not eligible for chunkAppend, but eligible for sort pushdown -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM mapc_test ORDER BY device, time DESC LIMIT 1; -- with pushdown QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -419,76 +347,57 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(30 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(21 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -(39 rows) + Rows Removed by Filter: 15967 +(29 rows) CREATE TABLE test1 ( time timestamptz NOT NULL, @@ -509,7 +418,7 @@ INSERT INTO test1 (time, x1, x2, x3, x4, x5) values('2000-01-01 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test1') i; compress_chunk ---------------------------------------- - _timescaledb_internal._hyper_3_7_chunk + _timescaledb_internal._hyper_3_5_chunk (1 row) ANALYZE test1; @@ -524,16 +433,16 @@ SELECT * FROM test1 ORDER BY time DESC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -544,16 +453,16 @@ SELECT * FROM test1 ORDER BY time DESC LIMIT 10; -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (14 rows) -- requires resorting @@ -564,16 +473,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) -- all these require resorting, no pushdown can happen @@ -584,16 +493,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 ASC NU Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -603,16 +512,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -622,16 +531,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -641,16 +550,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -660,16 +569,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -679,16 +588,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS FIRST, x3 DESC NULLS LAST, x4 ASC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" NULLS FIRST, test1.x3 DESC NULLS LAST, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) set max_parallel_workers_per_gather = 0; -- parallel plan different on Windows @@ -703,16 +612,16 @@ SELECT x1, x2, max(time) FROM test1 GROUP BY x1, x2, time ORDER BY time limit 10 -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x1, test1.x2 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (16 rows) reset max_parallel_workers_per_gather; @@ -723,16 +632,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, x4, time LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -741,16 +650,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -759,16 +668,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -777,16 +686,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3, x4 LIMIT 10; ---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -795,16 +704,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 DESC LIMIT 10; -- no pushdown ------------------------------------------------------------------------------------------------------------------------------------------ Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) -- queries with pushdown @@ -814,16 +723,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -832,16 +741,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time DESC, x3 ASC, x4 ASC LIMIT 10; -- --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -850,16 +759,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time ASC, x3 DESC, x4 DESC LIMIT 10; -- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -868,16 +777,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 DESC LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) --------------------------------------------------------------------------- @@ -905,10 +814,10 @@ INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 01:00:00-00', 1, INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 02:00:00-00', 2, 1, 3, 3, 0); INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, 2, 4, 4, 0); SELECT compress_chunk(i) FROM show_chunks('test2') i; - compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_5_9_chunk - _timescaledb_internal._hyper_5_10_chunk + compress_chunk +---------------------------------------- + _timescaledb_internal._hyper_5_7_chunk + _timescaledb_internal._hyper_5_8_chunk (2 rows) -- make them partially compressed @@ -920,25 +829,25 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3; @@ -960,25 +869,25 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; @@ -998,28 +907,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; -- queries where sort is not pushed down :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x3; - QUERY PLAN ----------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x3; @@ -1038,28 +947,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x3; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, x4; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------ Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x4; @@ -1078,28 +987,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x4; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, time; @@ -1150,10 +1059,10 @@ INSERT INTO test3 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test3') i; compress_chunk ----------------------------------------- + _timescaledb_internal._hyper_7_11_chunk + _timescaledb_internal._hyper_7_12_chunk _timescaledb_internal._hyper_7_13_chunk _timescaledb_internal._hyper_7_14_chunk - _timescaledb_internal._hyper_7_15_chunk - _timescaledb_internal._hyper_7_16_chunk (4 rows) -- make them partially compressed @@ -1165,7 +1074,21 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1180,20 +1103,6 @@ set enable_indexscan = off; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3; @@ -1215,7 +1124,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1230,20 +1153,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; @@ -1266,7 +1175,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; QUERY PLAN ---------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 Sort Method: quicksort @@ -1281,20 +1204,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x3; @@ -1316,7 +1225,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; QUERY PLAN ---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 Sort Method: quicksort @@ -1331,20 +1254,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x4; @@ -1366,7 +1275,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" Sort Method: quicksort @@ -1381,20 +1304,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, time; diff --git a/tsl/test/expected/transparent_decompression_ordered_index-14.out b/tsl/test/expected/transparent_decompression_ordered_index-14.out index 3d881d1adc5..831a2997445 100644 --- a/tsl/test/expected/transparent_decompression_ordered_index-14.out +++ b/tsl/test/expected/transparent_decompression_ordered_index-14.out @@ -699,20 +699,19 @@ ON met.device_id = q.node and met.device_id_peer = q.device_id_peer QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (actual rows=1 loops=1) - Join Filter: (nodetime.node = met.device_id) + Join Filter: (("*VALUES*".column2 = met.device_id_peer) AND ("*VALUES*".column3 = met.v0)) -> Nested Loop (actual rows=1 loops=1) Join Filter: (nodetime.node = "*VALUES*".column1) Rows Removed by Join Filter: 1 -> Seq Scan on nodetime (actual rows=1 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_4_chunk met (actual rows=1 loops=1) - Filter: ("*VALUES*".column3 = v0) - Rows Removed by Filter: 47 Vectorized Filter: ((v0 > 2) AND ("time" = 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) + Rows Removed by Filter: 47 -> Index Scan using compress_hyper_2_9_chunk_device_id_device_id_peer__ts_meta__idx on compress_hyper_2_9_chunk (actual rows=1 loops=1) - Index Cond: ((device_id = "*VALUES*".column1) AND (device_id_peer = "*VALUES*".column2)) + Index Cond: (device_id = nodetime.node) Filter: ((_ts_meta_min_1 <= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone) AND (_ts_meta_max_1 >= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) -(14 rows) +(13 rows) -- filter on compressed attr (v0) with seqscan enabled and indexscan -- disabled. filters on compressed attr should be above the seq scan. From a8f83e70cda2ce66b30d1c2bb512725864997651 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 25 Jan 2024 01:26:19 +0100 Subject: [PATCH 06/12] reference transparent_decompression_ordered_index-* merge_append_partially_compressed-* --- .../merge_append_partially_compressed-13.out | 915 ++++++++---------- ...sparent_decompression_ordered_index-13.out | 9 +- 2 files changed, 416 insertions(+), 508 deletions(-) diff --git a/tsl/test/expected/merge_append_partially_compressed-13.out b/tsl/test/expected/merge_append_partially_compressed-13.out index 4eaeecf4c02..5d328d32a80 100644 --- a/tsl/test/expected/merge_append_partially_compressed-13.out +++ b/tsl/test/expected/merge_append_partially_compressed-13.out @@ -7,72 +7,77 @@ set enable_parallel_append to off; -- for less flaky plans set timescaledb.enable_decompression_sorted_merge = off; \set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)' -CREATE TABLE ht_metrics_compressed(time timestamptz, device int, value float); -SELECT create_hypertable('ht_metrics_compressed','time'); +CREATE TABLE mapc_test(time timestamptz, device int, value float); +SELECT create_hypertable('mapc_test','time', create_default_indexes => false); NOTICE: adding not-null constraint to column "time" - create_hypertable ------------------------------------- - (1,public,ht_metrics_compressed,t) + create_hypertable +------------------------ + (1,public,mapc_test,t) (1 row) -ALTER TABLE ht_metrics_compressed SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); -INSERT INTO ht_metrics_compressed +ALTER TABLE mapc_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'6 hour') time, -generate_series(1,3) device; -SELECT compress_chunk(c) FROM show_chunks('ht_metrics_compressed') c; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 second') time, +generate_series(1,10) device; +select format('select count(*), min(time) from %s', x) from show_chunks('mapc_test') x \gexec +select count(*), min(time) from _timescaledb_internal._hyper_1_1_chunk + count | min +---------+------------------------------ + 1440000 | Thu Jan 02 00:00:00 2020 PST +(1 row) + +select count(*), min(time) from _timescaledb_internal._hyper_1_2_chunk + count | min +---------+------------------------------ + 1368010 | Wed Jan 08 16:00:00 2020 PST +(1 row) + +SELECT compress_chunk(c) FROM show_chunks('mapc_test') c; compress_chunk ---------------------------------------- _timescaledb_internal._hyper_1_1_chunk _timescaledb_internal._hyper_1_2_chunk - _timescaledb_internal._hyper_1_3_chunk -(3 rows) +(2 rows) -- make them partially compressed -INSERT INTO ht_metrics_compressed +INSERT INTO mapc_test SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'9 hour') time, -generate_series(1,3) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 minute') time, +generate_series(1,10) device; +create index on mapc_test(time); +analyze mapc_test; -- chunkAppend eligible queries (from tsbench) -- sort is not pushed down -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time DESC, device LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time DESC, device LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC, ht_metrics_compressed.device + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC, mapc_test.device -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device + Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC, _hyper_1_2_chunk.device - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC, _hyper_1_1_chunk.device -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -81,246 +86,188 @@ generate_series(1,3) device; -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1440000 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_1_chunk."time")) DESC, _hyper_1_1_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=84 loops=1) - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_2_chunk."time")) DESC, _hyper_1_2_chunk.device Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 1 day'::interval, _hyper_1_3_chunk."time")) DESC, _hyper_1_3_chunk.device - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(30 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(21 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time desc limit 10; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time desc limit 10; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=10 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=10 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=10 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Sort (actual rows=7 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: quicksort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) + -> Sort (actual rows=10 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) + Sort Method: top-N heapsort + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('2d',time) DESC LIMIT 1; - QUERY PLAN ----------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('2d',time) DESC LIMIT 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: time_bucket('@ 2 days'::interval, ht_metrics_compressed."time") DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: time_bucket('@ 2 days'::interval, mapc_test."time") DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC + Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1368010 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_3_chunk."time")) DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - -> Merge Append (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Sort (never executed) - Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - -> Seq Scan on compress_hyper_2_5_chunk (never executed) - -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_2_chunk."time")) DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) -> Merge Append (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) - -> Seq Scan on compress_hyper_2_4_chunk (never executed) + -> Seq Scan on compress_hyper_2_3_chunk (never executed) -> Sort (never executed) Sort Key: (time_bucket('@ 2 days'::interval, _hyper_1_1_chunk."time")) DESC -> Seq Scan on _hyper_1_1_chunk (never executed) -(32 rows) +(23 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC + Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=30 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=410403 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Sort (never executed) - Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 15967 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time", ht_metrics_compressed.device DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time", mapc_test.device DESC -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=81 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=432000 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time", _hyper_1_1_chunk.device DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time", _hyper_1_2_chunk.device DESC -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time", _hyper_1_3_chunk.device DESC - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = ANY ('{1,2,3}'::integer[])) -(41 rows) +(30 rows) -- index scan, no sort on top -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -- index scan, no resorting required +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" DESC + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" DESC -> Merge Append (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 - -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" DESC - -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) + -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) - -> Sort (never executed) + -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC - -> Seq Scan on _hyper_1_2_chunk (never executed) + Sort Method: top-N heapsort + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) + Rows Removed by Filter: 20529 -> Merge Append (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (never executed) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_1_chunk."time" DESC -> Seq Scan on _hyper_1_1_chunk (never executed) Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -- this uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -328,90 +275,71 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; Sort Key: _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=1 loops=1) + -> Index Scan Backward using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=19 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=2281 loops=1) Filter: (device = 3) - Rows Removed by Filter: 38 - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = 3) - -> Index Scan Backward using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=1 loops=1) - Index Cond: (device = 3) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=6 loops=1) - Filter: (device = 3) - Rows Removed by Filter: 12 -(33 rows) + Rows Removed by Filter: 20529 +(23 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; time | device | value ------------------------------+--------+------- - Sat Jan 18 00:00:00 2020 PST | 3 | 0.3 + Wed Jan 15 00:00:00 2020 PST | 3 | 0.3 (1 row) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- this also uses the index and does not do sort on top +-- index scan, no sort on top +:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) - -> Custom Scan (ChunkAppend) on ht_metrics_compressed (actual rows=1 loops=1) - Order: ht_metrics_compressed."time" + -> Custom Scan (ChunkAppend) on mapc_test (actual rows=1 loops=1) + Order: mapc_test."time" -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = 3) - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=1 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=1 loops=1) Index Cond: (device = 3) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk."time" Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=2400 loops=1) Filter: (device = 3) - Rows Removed by Filter: 36 + Rows Removed by Filter: 21600 -> Merge Append (never executed) Sort Key: _hyper_1_2_chunk."time" -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (never executed) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (never executed) Index Cond: (device = 3) -> Sort (never executed) Sort Key: _hyper_1_2_chunk."time" -> Seq Scan on _hyper_1_2_chunk (never executed) Filter: (device = 3) - -> Merge Append (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (never executed) - Filter: (device = 3) - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (never executed) - Index Cond: (device = 3) - -> Sort (never executed) - Sort Key: _hyper_1_3_chunk."time" - -> Seq Scan on _hyper_1_3_chunk (never executed) - Filter: (device = 3) -(35 rows) +(25 rows) -SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; time | device | value ------------------------------+--------+------- Thu Jan 02 00:00:00 2020 PST | 3 | 0.3 (1 row) -- not eligible for chunkAppend, but eligible for sort pushdown -:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM mapc_test ORDER BY device, time DESC LIMIT 1; -- with pushdown QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) @@ -419,76 +347,57 @@ SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_3_chunk (actual rows=1440 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=24000 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_2_4_chunk (actual rows=1370 loops=1) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Seq Scan on compress_hyper_2_6_chunk (actual rows=3 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) -(30 rows) + -> Seq Scan on _hyper_1_2_chunk (actual rows=22810 loops=1) +(21 rows) -:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- +:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=1 loops=1) -> Merge Append (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC -> Custom Scan (DecompressChunk) on _hyper_1_1_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_3_chunk.device, compress_hyper_2_3_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_3_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_3_chunk (actual rows=432 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_1_chunk.device, _hyper_1_1_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_1_chunk (actual rows=54 loops=1) + -> Seq Scan on _hyper_1_1_chunk (actual rows=7200 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) + Rows Removed by Filter: 16800 -> Custom Scan (DecompressChunk) on _hyper_1_2_chunk (actual rows=1 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Index Scan using compress_hyper_2_5_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_5_chunk (actual rows=3 loops=1) + -> Index Scan using compress_hyper_2_4_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_4_chunk (actual rows=411 loops=1) Index Cond: (device = ANY ('{1,2,3}'::integer[])) -> Sort (actual rows=1 loops=1) Sort Key: _hyper_1_2_chunk.device, _hyper_1_2_chunk."time" DESC Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_2_chunk (actual rows=57 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Custom Scan (DecompressChunk) on _hyper_1_3_chunk (actual rows=1 loops=1) - Filter: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_sequence_num DESC - Sort Method: quicksort - -> Index Scan using compress_hyper_2_6_chunk_device__ts_meta_sequence_num_idx on compress_hyper_2_6_chunk (actual rows=3 loops=1) - Index Cond: (device = ANY ('{1,2,3}'::integer[])) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_1_3_chunk.device, _hyper_1_3_chunk."time" DESC - Sort Method: top-N heapsort - -> Seq Scan on _hyper_1_3_chunk (actual rows=18 loops=1) + -> Seq Scan on _hyper_1_2_chunk (actual rows=6843 loops=1) Filter: (device = ANY ('{1,2,3}'::integer[])) -(39 rows) + Rows Removed by Filter: 15967 +(29 rows) CREATE TABLE test1 ( time timestamptz NOT NULL, @@ -509,7 +418,7 @@ INSERT INTO test1 (time, x1, x2, x3, x4, x5) values('2000-01-01 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test1') i; compress_chunk ---------------------------------------- - _timescaledb_internal._hyper_3_7_chunk + _timescaledb_internal._hyper_3_5_chunk (1 row) ANALYZE test1; @@ -524,16 +433,16 @@ SELECT * FROM test1 ORDER BY time DESC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -544,16 +453,16 @@ SELECT * FROM test1 ORDER BY time DESC LIMIT 10; -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC + Sort Key: _hyper_3_5_chunk."time" DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (14 rows) -- requires resorting @@ -564,16 +473,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) -- all these require resorting, no pushdown can happen @@ -584,16 +493,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 ASC NU Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -603,16 +512,16 @@ SELECT * FROM test1 ORDER BY time DESC NULLS FIRST, x3 ASC NULLS LAST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" DESC, test1.x3, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -622,16 +531,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -641,16 +550,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -660,16 +569,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS LAST, x3 DESC NULLS FIRST, x4 DESC N Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x3 DESC, test1.x4 DESC -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) :PREFIX @@ -679,16 +588,16 @@ SELECT * FROM test1 ORDER BY time ASC NULLS FIRST, x3 DESC NULLS LAST, x4 ASC; Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time" NULLS FIRST, test1.x3 DESC NULLS LAST, test1.x4 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time" NULLS FIRST, _hyper_3_7_chunk.x3 DESC NULLS LAST, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk."time" NULLS FIRST, _hyper_3_5_chunk.x3 DESC NULLS LAST, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (13 rows) set max_parallel_workers_per_gather = 0; -- parallel plan different on Windows @@ -703,16 +612,16 @@ SELECT x1, x2, max(time) FROM test1 GROUP BY x1, x2, time ORDER BY time limit 10 -> Custom Scan (ChunkAppend) on test1 (actual rows=5 loops=1) Order: test1."time", test1.x1, test1.x2 -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk."time", _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2 + Sort Key: _hyper_3_5_chunk."time", _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (16 rows) reset max_parallel_workers_per_gather; @@ -723,16 +632,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, x4, time LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk.x4, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk.x4, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -741,16 +650,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -759,16 +668,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 LIMIT 10; ------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -777,16 +686,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3, x4 LIMIT 10; ---------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -795,16 +704,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x4 DESC LIMIT 10; -- no pushdown ------------------------------------------------------------------------------------------------------------------------------------------ Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) -- queries with pushdown @@ -814,16 +723,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -832,13 +741,13 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time DESC, x3 ASC, x4 ASC LIMIT 10; -- --------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) - -> Index Scan using compress_hyper_4_8_chunk_x1_x2_x5__ts_meta_sequence_num_idx on compress_hyper_4_8_chunk (actual rows=3 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) + -> Index Scan using compress_hyper_4_6_chunk_x1_x2_x5__ts_meta_sequence_num_idx on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time" DESC, _hyper_3_7_chunk.x3, _hyper_3_7_chunk.x4 + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time" DESC, _hyper_3_5_chunk.x3, _hyper_3_5_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (9 rows) :PREFIX @@ -847,16 +756,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time ASC, x3 DESC, x4 DESC LIMIT 10; -- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC, _hyper_3_7_chunk.x4 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC, _hyper_3_5_chunk.x4 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) :PREFIX @@ -865,16 +774,16 @@ SELECT * FROM test1 ORDER BY x1, x2, x5, time, x3 DESC LIMIT 10; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=5 loops=1) -> Merge Append (actual rows=5 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC - -> Custom Scan (DecompressChunk) on _hyper_3_7_chunk (actual rows=4 loops=1) + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC + -> Custom Scan (DecompressChunk) on _hyper_3_5_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_4_8_chunk.x1, compress_hyper_4_8_chunk.x2, compress_hyper_4_8_chunk.x5, compress_hyper_4_8_chunk._ts_meta_sequence_num DESC + Sort Key: compress_hyper_4_6_chunk.x1, compress_hyper_4_6_chunk.x2, compress_hyper_4_6_chunk.x5, compress_hyper_4_6_chunk._ts_meta_sequence_num DESC Sort Method: quicksort - -> Seq Scan on compress_hyper_4_8_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_4_6_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_3_7_chunk.x1, _hyper_3_7_chunk.x2, _hyper_3_7_chunk.x5, _hyper_3_7_chunk."time", _hyper_3_7_chunk.x3 DESC + Sort Key: _hyper_3_5_chunk.x1, _hyper_3_5_chunk.x2, _hyper_3_5_chunk.x5, _hyper_3_5_chunk."time", _hyper_3_5_chunk.x3 DESC Sort Method: quicksort - -> Seq Scan on _hyper_3_7_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_3_5_chunk (actual rows=1 loops=1) (12 rows) --------------------------------------------------------------------------- @@ -902,10 +811,10 @@ INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 01:00:00-00', 1, INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 02:00:00-00', 2, 1, 3, 3, 0); INSERT INTO test2 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, 2, 4, 4, 0); SELECT compress_chunk(i) FROM show_chunks('test2') i; - compress_chunk ------------------------------------------ - _timescaledb_internal._hyper_5_9_chunk - _timescaledb_internal._hyper_5_10_chunk + compress_chunk +---------------------------------------- + _timescaledb_internal._hyper_5_7_chunk + _timescaledb_internal._hyper_5_8_chunk (2 rows) -- make them partially compressed @@ -917,25 +826,25 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3; @@ -957,25 +866,25 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_11_chunk.x1, compress_hyper_6_11_chunk.x2, compress_hyper_6_11_chunk.x5, compress_hyper_6_11_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_9_chunk.x1, compress_hyper_6_9_chunk.x2, compress_hyper_6_9_chunk.x5, compress_hyper_6_9_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x3, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x3, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) -> Sort (actual rows=3 loops=1) - Sort Key: compress_hyper_6_12_chunk.x1, compress_hyper_6_12_chunk.x2, compress_hyper_6_12_chunk.x5, compress_hyper_6_12_chunk._ts_meta_sequence_num + Sort Key: compress_hyper_6_10_chunk.x1, compress_hyper_6_10_chunk.x2, compress_hyper_6_10_chunk.x5, compress_hyper_6_10_chunk._ts_meta_sequence_num Sort Method: quicksort - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x3, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x3, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; @@ -995,28 +904,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x3, x4; -- queries where sort is not pushed down :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x3; - QUERY PLAN ----------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x3 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x3 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x3 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x3; @@ -1035,28 +944,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x3; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, x4; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------ Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk.x4 + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk.x4 + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk.x4 Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, x4; @@ -1075,28 +984,28 @@ SELECT * FROM test2 ORDER BY x1, x2, x5, x4; (10 rows) :PREFIX SELECT * FROM test2 ORDER BY x1, x2, x5, time; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_9_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_11_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_7_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_9_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_9_chunk.x1, _hyper_5_9_chunk.x2, _hyper_5_9_chunk.x5, _hyper_5_9_chunk."time" + Sort Key: _hyper_5_7_chunk.x1, _hyper_5_7_chunk.x2, _hyper_5_7_chunk.x5, _hyper_5_7_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_9_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_7_chunk (actual rows=1 loops=1) -> Sort (actual rows=4 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_5_10_chunk (actual rows=4 loops=1) - -> Seq Scan on compress_hyper_6_12_chunk (actual rows=3 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_5_8_chunk (actual rows=4 loops=1) + -> Seq Scan on compress_hyper_6_10_chunk (actual rows=3 loops=1) -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_5_10_chunk.x1, _hyper_5_10_chunk.x2, _hyper_5_10_chunk.x5, _hyper_5_10_chunk."time" + Sort Key: _hyper_5_8_chunk.x1, _hyper_5_8_chunk.x2, _hyper_5_8_chunk.x5, _hyper_5_8_chunk."time" Sort Method: quicksort - -> Seq Scan on _hyper_5_10_chunk (actual rows=1 loops=1) + -> Seq Scan on _hyper_5_8_chunk (actual rows=1 loops=1) (20 rows) SELECT * FROM test2 ORDER BY x1, x2, x5, time; @@ -1147,10 +1056,10 @@ INSERT INTO test3 (time, x1, x2, x3, x4, x5) values('2000-01-10 03:00:00-00', 1, SELECT compress_chunk(i) FROM show_chunks('test3') i; compress_chunk ----------------------------------------- + _timescaledb_internal._hyper_7_11_chunk + _timescaledb_internal._hyper_7_12_chunk _timescaledb_internal._hyper_7_13_chunk _timescaledb_internal._hyper_7_14_chunk - _timescaledb_internal._hyper_7_15_chunk - _timescaledb_internal._hyper_7_16_chunk (4 rows) -- make them partially compressed @@ -1162,7 +1071,21 @@ set enable_indexscan = off; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1177,20 +1100,6 @@ set enable_indexscan = off; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3; @@ -1212,7 +1121,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x3, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Sort (actual rows=2 loops=1) + Sort Key: compress_hyper_8_15_chunk.x1, compress_hyper_8_15_chunk.x2, compress_hyper_8_15_chunk.x5, compress_hyper_8_15_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x3, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: compress_hyper_8_16_chunk.x1, compress_hyper_8_16_chunk.x2, compress_hyper_8_16_chunk.x5, compress_hyper_8_16_chunk._ts_meta_sequence_num + Sort Method: quicksort + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Custom Scan (DecompressChunk) on _hyper_7_13_chunk (actual rows=3 loops=1) -> Sort (actual rows=2 loops=1) Sort Key: compress_hyper_8_17_chunk.x1, compress_hyper_8_17_chunk.x2, compress_hyper_8_17_chunk.x5, compress_hyper_8_17_chunk._ts_meta_sequence_num @@ -1227,20 +1150,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3; Sort Key: compress_hyper_8_18_chunk.x1, compress_hyper_8_18_chunk.x2, compress_hyper_8_18_chunk.x5, compress_hyper_8_18_chunk._ts_meta_sequence_num Sort Method: quicksort -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Sort (actual rows=2 loops=1) - Sort Key: compress_hyper_8_19_chunk.x1, compress_hyper_8_19_chunk.x2, compress_hyper_8_19_chunk.x5, compress_hyper_8_19_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x3, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: compress_hyper_8_20_chunk.x1, compress_hyper_8_20_chunk.x2, compress_hyper_8_20_chunk.x5, compress_hyper_8_20_chunk._ts_meta_sequence_num - Sort Method: quicksort - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; @@ -1263,7 +1172,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; QUERY PLAN ---------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x3 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x3 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x3 Sort Method: quicksort @@ -1278,20 +1201,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x3, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x3 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x3 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x3; @@ -1313,7 +1222,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; QUERY PLAN ---------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk.x4 + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk.x4 + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk.x4 Sort Method: quicksort @@ -1328,20 +1251,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x3; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk.x4 - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk.x4 - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, x4; @@ -1363,7 +1272,21 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Merge Append (actual rows=10 loops=1) - Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + -> Sort (actual rows=3 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_11_chunk (actual rows=3 loops=1) + -> Seq Scan on compress_hyper_8_15_chunk (actual rows=2 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_11_chunk.x1, _hyper_7_11_chunk.x2, _hyper_7_11_chunk.x5, _hyper_7_11_chunk."time" + Sort Method: quicksort + -> Seq Scan on _hyper_7_11_chunk (actual rows=1 loops=1) + -> Sort (actual rows=1 loops=1) + Sort Key: _hyper_7_12_chunk.x1, _hyper_7_12_chunk.x2, _hyper_7_12_chunk.x5, _hyper_7_12_chunk."time" + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_7_12_chunk (actual rows=1 loops=1) + -> Seq Scan on compress_hyper_8_16_chunk (actual rows=1 loops=1) -> Sort (actual rows=3 loops=1) Sort Key: _hyper_7_13_chunk.x1, _hyper_7_13_chunk.x2, _hyper_7_13_chunk.x5, _hyper_7_13_chunk."time" Sort Method: quicksort @@ -1378,20 +1301,6 @@ SELECT * FROM test3 ORDER BY x1, x2, x5, x4; Sort Method: quicksort -> Custom Scan (DecompressChunk) on _hyper_7_14_chunk (actual rows=1 loops=1) -> Seq Scan on compress_hyper_8_18_chunk (actual rows=1 loops=1) - -> Sort (actual rows=3 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_15_chunk (actual rows=3 loops=1) - -> Seq Scan on compress_hyper_8_19_chunk (actual rows=2 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_15_chunk.x1, _hyper_7_15_chunk.x2, _hyper_7_15_chunk.x5, _hyper_7_15_chunk."time" - Sort Method: quicksort - -> Seq Scan on _hyper_7_15_chunk (actual rows=1 loops=1) - -> Sort (actual rows=1 loops=1) - Sort Key: _hyper_7_16_chunk.x1, _hyper_7_16_chunk.x2, _hyper_7_16_chunk.x5, _hyper_7_16_chunk."time" - Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_7_16_chunk (actual rows=1 loops=1) - -> Seq Scan on compress_hyper_8_20_chunk (actual rows=1 loops=1) (30 rows) SELECT * FROM test3 ORDER BY x1, x2, x5, time; diff --git a/tsl/test/expected/transparent_decompression_ordered_index-13.out b/tsl/test/expected/transparent_decompression_ordered_index-13.out index c6ad63745c1..8f6d4506504 100644 --- a/tsl/test/expected/transparent_decompression_ordered_index-13.out +++ b/tsl/test/expected/transparent_decompression_ordered_index-13.out @@ -699,20 +699,19 @@ ON met.device_id = q.node and met.device_id_peer = q.device_id_peer QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (actual rows=1 loops=1) - Join Filter: (nodetime.node = met.device_id) + Join Filter: (("*VALUES*".column2 = met.device_id_peer) AND ("*VALUES*".column3 = met.v0)) -> Nested Loop (actual rows=1 loops=1) Join Filter: (nodetime.node = "*VALUES*".column1) Rows Removed by Join Filter: 1 -> Seq Scan on nodetime (actual rows=1 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) -> Custom Scan (DecompressChunk) on _hyper_1_4_chunk met (actual rows=1 loops=1) - Filter: ("*VALUES*".column3 = v0) - Rows Removed by Filter: 47 Vectorized Filter: ((v0 > 2) AND ("time" = 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) + Rows Removed by Filter: 47 -> Index Scan using compress_hyper_2_9_chunk_device_id_device_id_peer__ts_meta__idx on compress_hyper_2_9_chunk (actual rows=1 loops=1) - Index Cond: ((device_id = "*VALUES*".column1) AND (device_id_peer = "*VALUES*".column2)) + Index Cond: (device_id = nodetime.node) Filter: ((_ts_meta_min_1 <= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone) AND (_ts_meta_max_1 >= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) -(14 rows) +(13 rows) -- filter on compressed attr (v0) with seqscan enabled and indexscan -- disabled. filters on compressed attr should be above the seq scan. From b822a4e077e7ebe431f46c0878813d5a2c036811 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:26:40 +0100 Subject: [PATCH 07/12] reference transparent_decompress_chunk-* --- .../transparent_decompress_chunk-13.out | 94 ++++++++----------- 1 file changed, 38 insertions(+), 56 deletions(-) diff --git a/tsl/test/shared/expected/transparent_decompress_chunk-13.out b/tsl/test/shared/expected/transparent_decompress_chunk-13.out index e08e7de6a01..2727424ba19 100644 --- a/tsl/test/shared/expected/transparent_decompress_chunk-13.out +++ b/tsl/test/shared/expected/transparent_decompress_chunk-13.out @@ -185,18 +185,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id = v0 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (device_id = v0) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (device_id = v0) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id < v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -227,14 +223,12 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id = length(substring(version(), 1, 3)) ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id = length("substring"(version(), 1, 3))) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id = length("substring"(version(), 1, 3))) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test segment meta pushdown -- order by column and const @@ -316,18 +310,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < 1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Vectorized Filter: (v0 < 1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Vectorized Filter: (v0 < 1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -363,35 +353,27 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v1 = device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v1 = device_id) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v1 = device_id) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown between two order by column (not pushed down) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 = v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v0 = v1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v0 = v1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown of quals on order by and segment by cols anded together :PREFIX_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' AND device_id = 1 ORDER BY time, device_id LIMIT 10; From 713d4e311a50f1291dc88140fc6118461653e6a3 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:27:03 +0100 Subject: [PATCH 08/12] reference transparent_decompress_chunk-* --- .../transparent_decompress_chunk-16.out | 94 ++++++++----------- 1 file changed, 38 insertions(+), 56 deletions(-) diff --git a/tsl/test/shared/expected/transparent_decompress_chunk-16.out b/tsl/test/shared/expected/transparent_decompress_chunk-16.out index 1b920f8f970..05b7d0a8039 100644 --- a/tsl/test/shared/expected/transparent_decompress_chunk-16.out +++ b/tsl/test/shared/expected/transparent_decompress_chunk-16.out @@ -187,18 +187,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id = v0 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (device_id = v0) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (device_id = v0) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id < v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -229,14 +225,12 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id = length(substring(version(), 1, 3)) ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id = length("substring"(version(), 1, 3))) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id = length("substring"(version(), 1, 3))) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test segment meta pushdown -- order by column and const @@ -318,18 +312,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < 1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Vectorized Filter: (v0 < 1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Vectorized Filter: (v0 < 1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -365,35 +355,27 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v1 = device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v1 = device_id) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v1 = device_id) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown between two order by column (not pushed down) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 = v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v0 = v1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v0 = v1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown of quals on order by and segment by cols anded together :PREFIX_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' AND device_id = 1 ORDER BY time, device_id LIMIT 10; From a7ddc1f1b45c5a300549ae0503f1e7f72260df09 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:27:40 +0100 Subject: [PATCH 09/12] reference transparent_decompress_chunk-* --- .../transparent_decompress_chunk-14.out | 94 ++++++++----------- 1 file changed, 38 insertions(+), 56 deletions(-) diff --git a/tsl/test/shared/expected/transparent_decompress_chunk-14.out b/tsl/test/shared/expected/transparent_decompress_chunk-14.out index e08e7de6a01..2727424ba19 100644 --- a/tsl/test/shared/expected/transparent_decompress_chunk-14.out +++ b/tsl/test/shared/expected/transparent_decompress_chunk-14.out @@ -185,18 +185,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id = v0 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (device_id = v0) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (device_id = v0) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id < v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -227,14 +223,12 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id = length(substring(version(), 1, 3)) ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id = length("substring"(version(), 1, 3))) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id = length("substring"(version(), 1, 3))) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test segment meta pushdown -- order by column and const @@ -316,18 +310,14 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < 1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Vectorized Filter: (v0 < 1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Vectorized Filter: (v0 < 1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 < device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -363,35 +353,27 @@ QUERY PLAN :PREFIX SELECT * FROM :TEST_TABLE WHERE v1 = device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v1 = device_id) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v1 = device_id) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown between two order by column (not pushed down) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 = v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v0 = v1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v0 = v1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown of quals on order by and segment by cols anded together :PREFIX_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' AND device_id = 1 ORDER BY time, device_id LIMIT 10; From afcbe749b95884cf9e8f986c2cb4f545684bf82e Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:16:23 +0100 Subject: [PATCH 10/12] size fixes --- .../nodes/decompress_chunk/decompress_chunk.c | 125 ++++++++++-------- .../nodes/decompress_chunk/decompress_chunk.h | 2 +- tsl/src/nodes/decompress_chunk/planner.c | 9 +- 3 files changed, 78 insertions(+), 58 deletions(-) diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.c b/tsl/src/nodes/decompress_chunk/decompress_chunk.c index 57b61b17ca0..7cedee551dc 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.c +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.c @@ -46,7 +46,7 @@ static CustomPathMethods decompress_chunk_path_methods = { typedef struct SortInfo { - List *compressed_pathkeys; + List *required_compressed_pathkeys; bool needs_sequence_num; bool can_pushdown_sort; /* sort can be pushed below DecompressChunk */ bool reverse; @@ -153,7 +153,7 @@ build_compressed_scan_pathkeys(SortInfo *sort_info, PlannerInfo *root, List *chu { Var *var; int varattno; - List *compressed_pathkeys = NIL; + List *required_compressed_pathkeys = NIL; PathKey *pk; /* @@ -198,7 +198,7 @@ build_compressed_scan_pathkeys(SortInfo *sort_info, PlannerInfo *root, List *chu */ Assert(compressed_em != NULL); - compressed_pathkeys = lappend(compressed_pathkeys, pk); + required_compressed_pathkeys = lappend(required_compressed_pathkeys, pk); segmentby_columns = bms_add_member(segmentby_columns, castNode(Var, compressed_em->em_expr)->varattno); @@ -210,7 +210,7 @@ build_compressed_scan_pathkeys(SortInfo *sort_info, PlannerInfo *root, List *chu * asserting here. */ Assert(bms_num_members(segmentby_columns) == info->num_segmentby_columns || - list_length(compressed_pathkeys) == list_length(chunk_pathkeys)); + list_length(required_compressed_pathkeys) == list_length(chunk_pathkeys)); } /* @@ -251,9 +251,9 @@ build_compressed_scan_pathkeys(SortInfo *sort_info, PlannerInfo *root, List *chu pk = make_canonical_pathkey(root, ec, opfamily, strategy, nulls_first); - compressed_pathkeys = lappend(compressed_pathkeys, pk); + required_compressed_pathkeys = lappend(required_compressed_pathkeys, pk); } - sort_info->compressed_pathkeys = compressed_pathkeys; + sort_info->required_compressed_pathkeys = required_compressed_pathkeys; } static DecompressChunkPath * @@ -323,14 +323,22 @@ build_compressioninfo(PlannerInfo *root, Hypertable *ht, RelOptInfo *chunk_rel) static void cost_decompress_chunk(PlannerInfo *root, Path *path, Path *compressed_path) { + /* Set the row number estimate. */ + if (path->param_info != NULL) + { + path->rows = path->param_info->ppi_rows; + } + else + { + path->rows = path->parent->rows; + } + /* startup_cost is cost before fetching first tuple */ if (compressed_path->rows > 0) path->startup_cost = compressed_path->total_cost / compressed_path->rows; /* total_cost is cost for fetching all tuples */ path->total_cost = compressed_path->total_cost + path->rows * cpu_tuple_cost; - path->rows = compressed_path->rows * DECOMPRESS_CHUNK_BATCH_SIZE * - clauselist_selectivity(root, path->parent->baserestrictinfo, 0, JOIN_INNER, NULL); } /* Smoothstep function S1 (the h01 cubic Hermite spline). */ @@ -361,7 +369,7 @@ cost_batch_sorted_merge(PlannerInfo *root, CompressionInfo *compression_info, enable_sort = true; cost_sort(&sort_path, root, - dcpath->compressed_pathkeys, + dcpath->required_compressed_pathkeys, compressed_path->total_cost, compressed_path->rows, compressed_path->pathtarget->width, @@ -691,7 +699,6 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp { RelOptInfo *compressed_rel; ListCell *lc; - double new_row_estimate; Index ht_relid = 0; CompressionInfo *compression_info = build_compressioninfo(root, ht, chunk_rel); @@ -725,8 +732,12 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp chunk_rel, compressed_rel, ts_chunk_is_partial(chunk)); + set_baserel_size_estimates(root, compressed_rel); - new_row_estimate = compressed_rel->rows * DECOMPRESS_CHUNK_BATCH_SIZE; + const double new_tuples_estimate = compressed_rel->rows * DECOMPRESS_CHUNK_BATCH_SIZE; + const double new_rows_estimate = + new_tuples_estimate * + clauselist_selectivity(root, chunk_rel->baserestrictinfo, 0, JOIN_INNER, NULL); if (!compression_info->single_chunk) { @@ -735,10 +746,19 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp Assert(chunk_info->parent_reloid == ht->main_table_relid); ht_relid = chunk_info->parent_relid; RelOptInfo *hypertable_rel = root->simple_rel_array[ht_relid]; - hypertable_rel->rows += (new_row_estimate - chunk_rel->rows); + hypertable_rel->rows = + clamp_row_est(hypertable_rel->rows + new_rows_estimate - chunk_rel->rows); + hypertable_rel->tuples = + clamp_row_est(hypertable_rel->tuples + new_tuples_estimate - chunk_rel->tuples); } - chunk_rel->rows = new_row_estimate; + /* + * Note that we can be overwriting the estimate for uncompressed chunk part of a + * partial chunk here, but the paths for the uncompressed part were already + * built, so it is OK. + */ + chunk_rel->tuples = new_tuples_estimate; + chunk_rel->rows = new_rows_estimate; create_compressed_scan_paths(root, compressed_rel, compression_info, &sort_info); @@ -751,7 +771,6 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp foreach (lc, compressed_rel->pathlist) { Path *compressed_path = lfirst(lc); - Path *path; /* * We skip any BitmapScan parameterized paths here as supporting @@ -831,7 +850,8 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp continue; } - path = (Path *) decompress_chunk_path_create(root, compression_info, 0, compressed_path); + Path *chunk_path = + (Path *) decompress_chunk_path_create(root, compression_info, 0, compressed_path); /* * Create a path for the batch sorted merge optimization. This optimization performs a @@ -847,7 +867,7 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp MergeBatchResult merge_result = can_batch_sorted_merge(root, compression_info, chunk); if (merge_result != MERGE_NOT_POSSIBLE) { - batch_merge_path = copy_decompress_chunk_path((DecompressChunkPath *) path); + batch_merge_path = copy_decompress_chunk_path((DecompressChunkPath *) chunk_path); batch_merge_path->reverse = (merge_result != SCAN_FORWARD); batch_merge_path->batch_sorted_merge = true; @@ -874,11 +894,12 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp * between the decompression node and the scan during plan creation */ if (sort_info.can_pushdown_sort) { - DecompressChunkPath *dcpath = copy_decompress_chunk_path((DecompressChunkPath *) path); - dcpath->reverse = sort_info.reverse; - dcpath->needs_sequence_num = sort_info.needs_sequence_num; - dcpath->compressed_pathkeys = sort_info.compressed_pathkeys; - dcpath->custom_path.path.pathkeys = root->query_pathkeys; + DecompressChunkPath *path_copy = + copy_decompress_chunk_path((DecompressChunkPath *) chunk_path); + path_copy->reverse = sort_info.reverse; + path_copy->needs_sequence_num = sort_info.needs_sequence_num; + path_copy->required_compressed_pathkeys = sort_info.required_compressed_pathkeys; + path_copy->custom_path.path.pathkeys = root->query_pathkeys; /* * Add costing for a sort. The standard Postgres pattern is to add the cost during @@ -886,13 +907,14 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp * creation. Examples of this in: create_merge_append_path & * create_merge_append_plan */ - if (!pathkeys_contained_in(dcpath->compressed_pathkeys, compressed_path->pathkeys)) + if (!pathkeys_contained_in(sort_info.required_compressed_pathkeys, + compressed_path->pathkeys)) { Path sort_path; /* dummy for result of cost_sort */ cost_sort(&sort_path, root, - dcpath->compressed_pathkeys, + sort_info.required_compressed_pathkeys, compressed_path->total_cost, compressed_path->rows, compressed_path->pathtarget->width, @@ -900,16 +922,10 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp work_mem, -1); - cost_decompress_chunk(root, &dcpath->custom_path.path, &sort_path); + cost_decompress_chunk(root, &path_copy->custom_path.path, &sort_path); } - /* - * if chunk is partially compressed don't add this now but add an append path later - * combining the uncompressed and compressed parts of the chunk - */ - if (!ts_chunk_is_partial(chunk)) - add_path(chunk_rel, &dcpath->custom_path.path); - else - path = &dcpath->custom_path.path; + + chunk_path = &path_copy->custom_path.path; } /* @@ -918,7 +934,7 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp */ if (ts_chunk_is_partial(chunk)) { - Bitmapset *req_outer = PATH_REQ_OUTER(path); + Bitmapset *req_outer = PATH_REQ_OUTER(chunk_path); Path *uncompressed_path = get_cheapest_path_for_pathkeys(initial_pathlist, NIL, req_outer, TOTAL_COST, false); @@ -941,13 +957,13 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp */ if (batch_merge_path != NULL) { - path = (Path *) create_merge_append_path_compat(root, - chunk_rel, - list_make2(batch_merge_path, - uncompressed_path), - root->query_pathkeys, - req_outer, - NIL); + chunk_path = (Path *) create_merge_append_path_compat(root, + chunk_rel, + list_make2(batch_merge_path, + uncompressed_path), + root->query_pathkeys, + req_outer, + NIL); } else /* @@ -956,24 +972,25 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp * and directly add its children, so we have to combine the children * into a MergeAppend node later, at the chunk append level. */ - path = (Path *) create_append_path_compat(root, - chunk_rel, - list_make2(path, uncompressed_path), - NIL /* partial paths */, - root->query_pathkeys /* pathkeys */, - req_outer, - 0, - false, - false, - path->rows + uncompressed_path->rows); + chunk_path = + (Path *) create_append_path_compat(root, + chunk_rel, + list_make2(chunk_path, uncompressed_path), + NIL /* partial paths */, + root->query_pathkeys /* pathkeys */, + req_outer, + 0, + false, + false, + chunk_path->rows + uncompressed_path->rows); } /* Add useful sorted versions of the decompress path */ - add_chunk_sorted_paths(root, chunk_rel, ht, ht_relid, path, compressed_path); + add_chunk_sorted_paths(root, chunk_rel, ht, ht_relid, chunk_path, compressed_path); /* this has to go after the path is copied for the ordered path since path can get freed in * add_path */ - add_path(chunk_rel, path); + add_path(chunk_rel, chunk_path); } /* the chunk_rel now owns the paths, remove them from the compressed_rel so they can't be freed @@ -1749,7 +1766,7 @@ decompress_chunk_path_create(PlannerInfo *root, CompressionInfo *info, int paral path->custom_path.custom_paths = list_make1(compressed_path); path->reverse = false; - path->compressed_pathkeys = NIL; + path->required_compressed_pathkeys = NIL; cost_decompress_chunk(root, &path->custom_path.path, compressed_path); return path; @@ -1819,7 +1836,7 @@ create_compressed_scan_paths(PlannerInfo *root, RelOptInfo *compressed_rel, Comp */ List *orig_pathkeys = root->query_pathkeys; build_compressed_scan_pathkeys(sort_info, root, root->query_pathkeys, info); - root->query_pathkeys = sort_info->compressed_pathkeys; + root->query_pathkeys = sort_info->required_compressed_pathkeys; check_index_predicates(root, compressed_rel); create_index_paths(root, compressed_rel); root->query_pathkeys = orig_pathkeys; diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.h b/tsl/src/nodes/decompress_chunk/decompress_chunk.h index 624bffd4ef7..a320fc23d11 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.h +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.h @@ -108,7 +108,7 @@ typedef struct DecompressChunkPath */ List *aggregated_column_type; - List *compressed_pathkeys; + List *required_compressed_pathkeys; bool needs_sequence_num; bool reverse; bool batch_sorted_merge; diff --git a/tsl/src/nodes/decompress_chunk/planner.c b/tsl/src/nodes/decompress_chunk/planner.c index ea609c241ce..fa2c7094465 100644 --- a/tsl/src/nodes/decompress_chunk/planner.c +++ b/tsl/src/nodes/decompress_chunk/planner.c @@ -939,7 +939,7 @@ decompress_chunk_plan_create(PlannerInfo *root, RelOptInfo *rel, CustomPath *pat collations, nullsFirst); - ts_label_sort_with_costsize(root, sort, /* limit_tuples = */ 0); + ts_label_sort_with_costsize(root, sort, /* limit_tuples = */ -1.0); decompress_plan->custom_plans = list_make1(sort); } @@ -948,12 +948,15 @@ decompress_chunk_plan_create(PlannerInfo *root, RelOptInfo *rel, CustomPath *pat /* * Add a sort if the compressed scan is not ordered appropriately. */ - if (!pathkeys_contained_in(dcpath->compressed_pathkeys, compressed_path->pathkeys)) + if (!pathkeys_contained_in(dcpath->required_compressed_pathkeys, compressed_path->pathkeys)) { - List *compressed_pks = dcpath->compressed_pathkeys; + List *compressed_pks = dcpath->required_compressed_pathkeys; Sort *sort = ts_make_sort_from_pathkeys((Plan *) compressed_scan, compressed_pks, bms_make_singleton(compressed_scan->scanrelid)); + + ts_label_sort_with_costsize(root, sort, /* limit_tuples = */ -1.0); + decompress_plan->custom_plans = list_make1(sort); } else From 9b83c131b081bb53b3e8c9de8a07f8e96886d1cf Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:40:57 +0100 Subject: [PATCH 11/12] fixes after merge --- .../nodes/decompress_chunk/decompress_chunk.c | 2 +- ...sparent_decompression_ordered_index-15.out | 40 ++- tsl/test/expected/vectorized_aggregation.out | 135 ++++---- .../transparent_decompress_chunk-15.out | 298 ++++++++---------- .../merge_append_partially_compressed.sql.in | 59 ++-- 5 files changed, 242 insertions(+), 292 deletions(-) diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.c b/tsl/src/nodes/decompress_chunk/decompress_chunk.c index dc00a2b2c40..dcf932b3431 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.c +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.c @@ -877,7 +877,7 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, con pushdown_quals(root, compression_info->settings, chunk_rel, compressed_rel, consider_partial); set_baserel_size_estimates(root, compressed_rel); - const double new_tuples_estimate = compressed_rel->rows * DECOMPRESS_CHUNK_BATCH_SIZE; + const double new_tuples_estimate = compressed_rel->rows * TARGET_COMPRESSED_BATCH_SIZE; const double new_rows_estimate = new_tuples_estimate * clauselist_selectivity(root, chunk_rel->baserestrictinfo, 0, JOIN_INNER, NULL); diff --git a/tsl/test/expected/transparent_decompression_ordered_index-15.out b/tsl/test/expected/transparent_decompression_ordered_index-15.out index 6e0802e055b..e130f2d092c 100644 --- a/tsl/test/expected/transparent_decompression_ordered_index-15.out +++ b/tsl/test/expected/transparent_decompression_ordered_index-15.out @@ -690,22 +690,20 @@ JOIN LATERAL WHERE node = f1.device_id) q ON met.device_id = q.node and met.device_id_peer = q.device_id_peer and met.v0 = q.v0 and met.v0 > 2 and time = '2018-01-19 20:00:00-05'; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (actual rows=1 loops=1) - Join Filter: (nodetime.node = met.device_id) + Join Filter: ("*VALUES*".column1 = nodetime.node) -> Nested Loop (actual rows=1 loops=1) - Join Filter: (nodetime.node = "*VALUES*".column1) - Rows Removed by Join Filter: 1 - -> Seq Scan on nodetime (actual rows=1 loops=1) -> Values Scan on "*VALUES*" (actual rows=2 loops=1) - -> Custom Scan (DecompressChunk) on _hyper_1_4_chunk met (actual rows=1 loops=1) - Filter: ("*VALUES*".column3 = v0) - Rows Removed by Filter: 47 - Vectorized Filter: ((v0 > 2) AND ("time" = 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) - -> Index Scan using compress_hyper_2_9_chunk_device_id_device_id_peer__ts_meta__idx on compress_hyper_2_9_chunk (actual rows=1 loops=1) - Index Cond: ((device_id = "*VALUES*".column1) AND (device_id_peer = "*VALUES*".column2) AND (_ts_meta_min_1 <= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone) AND (_ts_meta_max_1 >= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) -(13 rows) + -> Custom Scan (DecompressChunk) on _hyper_1_4_chunk met (actual rows=0 loops=2) + Filter: ("*VALUES*".column3 = v0) + Rows Removed by Filter: 24 + Vectorized Filter: ((v0 > 2) AND ("time" = 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) + -> Index Scan using compress_hyper_2_9_chunk_device_id_device_id_peer__ts_meta__idx on compress_hyper_2_9_chunk (actual rows=0 loops=2) + Index Cond: ((device_id = "*VALUES*".column1) AND (device_id_peer = "*VALUES*".column2) AND (_ts_meta_min_1 <= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone) AND (_ts_meta_max_1 >= 'Fri Jan 19 17:00:00 2018 PST'::timestamp with time zone)) + -> Seq Scan on nodetime (actual rows=1 loops=1) +(11 rows) -- filter on compressed attr (v0) with seqscan enabled and indexscan -- disabled. filters on compressed attr should be above the seq scan. @@ -841,24 +839,22 @@ GROUP BY m.device_id, ORDER BY 1, 2, 3; - QUERY PLAN ----------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------- Sort (actual rows=0 loops=1) Sort Key: m.device_id, d.v0, (count(*)) Sort Method: quicksort -> HashAggregate (actual rows=0 loops=1) Group Key: m.device_id, d.v0 Batches: 1 - -> Hash Join (actual rows=0 loops=1) - Hash Cond: ((d.device_id = m.device_id) AND (d."time" = m."time")) + -> Nested Loop (actual rows=0 loops=1) -> Custom Scan (ConstraintAwareAppend) (actual rows=0 loops=1) Hypertable: metrics_ordered_idx Chunks excluded during startup: 2 - -> Hash (never executed) - -> Custom Scan (ConstraintAwareAppend) (never executed) - Hypertable: metrics_ordered_idx - Chunks excluded during startup: 2 -(15 rows) + -> Custom Scan (ConstraintAwareAppend) (never executed) + Hypertable: metrics_ordered_idx + Chunks excluded during startup: 2 +(13 rows) --query with no results -- :PREFIX diff --git a/tsl/test/expected/vectorized_aggregation.out b/tsl/test/expected/vectorized_aggregation.out index 8887dac8469..45bf3e901f1 100644 --- a/tsl/test/expected/vectorized_aggregation.out +++ b/tsl/test/expected/vectorized_aggregation.out @@ -183,77 +183,74 @@ SELECT sum(segment_by_value) FROM testtable WHERE segment_by_value > 0; -- Vectorization not possible due to a used filter :EXPLAIN SELECT sum(segment_by_value) FROM testtable WHERE segment_by_value > 0 AND int_value > 0; - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Finalize Aggregate Output: sum(_hyper_1_1_chunk.segment_by_value) - -> Gather - Output: (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) - Workers Planned: 2 - -> Parallel Append - -> Custom Scan (VectorAgg) - Output: (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) - Grouping Policy: all compressed batches - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk - Output: _hyper_1_1_chunk.segment_by_value - Vectorized Filter: (_hyper_1_1_chunk.int_value > 0) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk - Output: compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1, compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value - Filter: (compress_hyper_2_11_chunk.segment_by_value > 0) - -> Custom Scan (VectorAgg) - Output: (PARTIAL sum(_hyper_1_2_chunk.segment_by_value)) - Grouping Policy: all compressed batches - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk - Output: _hyper_1_2_chunk.segment_by_value - Vectorized Filter: (_hyper_1_2_chunk.int_value > 0) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk - Output: compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1, compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value - Filter: (compress_hyper_2_12_chunk.segment_by_value > 0) - -> Custom Scan (VectorAgg) - Output: (PARTIAL sum(_hyper_1_3_chunk.segment_by_value)) - Grouping Policy: all compressed batches - -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk - Output: _hyper_1_3_chunk.segment_by_value - Vectorized Filter: (_hyper_1_3_chunk.int_value > 0) - -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk - Output: compress_hyper_2_13_chunk._ts_meta_count, compress_hyper_2_13_chunk.segment_by_value, compress_hyper_2_13_chunk._ts_meta_min_1, compress_hyper_2_13_chunk._ts_meta_max_1, compress_hyper_2_13_chunk."time", compress_hyper_2_13_chunk.int_value, compress_hyper_2_13_chunk.float_value - Filter: (compress_hyper_2_13_chunk.segment_by_value > 0) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_4_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_4_chunk - Output: _hyper_1_4_chunk.segment_by_value - Filter: ((_hyper_1_4_chunk.segment_by_value > 0) AND (_hyper_1_4_chunk.int_value > 0)) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_5_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_5_chunk - Output: _hyper_1_5_chunk.segment_by_value - Filter: ((_hyper_1_5_chunk.segment_by_value > 0) AND (_hyper_1_5_chunk.int_value > 0)) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_6_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_6_chunk - Output: _hyper_1_6_chunk.segment_by_value - Filter: ((_hyper_1_6_chunk.segment_by_value > 0) AND (_hyper_1_6_chunk.int_value > 0)) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_7_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_7_chunk - Output: _hyper_1_7_chunk.segment_by_value - Filter: ((_hyper_1_7_chunk.segment_by_value > 0) AND (_hyper_1_7_chunk.int_value > 0)) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_8_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_8_chunk - Output: _hyper_1_8_chunk.segment_by_value - Filter: ((_hyper_1_8_chunk.segment_by_value > 0) AND (_hyper_1_8_chunk.int_value > 0)) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_9_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_9_chunk - Output: _hyper_1_9_chunk.segment_by_value - Filter: ((_hyper_1_9_chunk.segment_by_value > 0) AND (_hyper_1_9_chunk.int_value > 0)) - -> Partial Aggregate - Output: PARTIAL sum(_hyper_1_10_chunk.segment_by_value) - -> Parallel Seq Scan on _timescaledb_internal._hyper_1_10_chunk - Output: _hyper_1_10_chunk.segment_by_value - Filter: ((_hyper_1_10_chunk.segment_by_value > 0) AND (_hyper_1_10_chunk.int_value > 0)) -(68 rows) + -> Append + -> Custom Scan (VectorAgg) + Output: (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) + Grouping Policy: all compressed batches + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk + Output: _hyper_1_1_chunk.segment_by_value + Vectorized Filter: (_hyper_1_1_chunk.int_value > 0) + -> Index Scan using compress_hyper_2_11_chunk_segment_by_value__ts_meta_min_1___idx on _timescaledb_internal.compress_hyper_2_11_chunk + Output: compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1, compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value + Index Cond: (compress_hyper_2_11_chunk.segment_by_value > 0) + -> Custom Scan (VectorAgg) + Output: (PARTIAL sum(_hyper_1_2_chunk.segment_by_value)) + Grouping Policy: all compressed batches + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk + Output: _hyper_1_2_chunk.segment_by_value + Vectorized Filter: (_hyper_1_2_chunk.int_value > 0) + -> Index Scan using compress_hyper_2_12_chunk_segment_by_value__ts_meta_min_1___idx on _timescaledb_internal.compress_hyper_2_12_chunk + Output: compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1, compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value + Index Cond: (compress_hyper_2_12_chunk.segment_by_value > 0) + -> Custom Scan (VectorAgg) + Output: (PARTIAL sum(_hyper_1_3_chunk.segment_by_value)) + Grouping Policy: all compressed batches + -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk + Output: _hyper_1_3_chunk.segment_by_value + Vectorized Filter: (_hyper_1_3_chunk.int_value > 0) + -> Index Scan using compress_hyper_2_13_chunk_segment_by_value__ts_meta_min_1___idx on _timescaledb_internal.compress_hyper_2_13_chunk + Output: compress_hyper_2_13_chunk._ts_meta_count, compress_hyper_2_13_chunk.segment_by_value, compress_hyper_2_13_chunk._ts_meta_min_1, compress_hyper_2_13_chunk._ts_meta_max_1, compress_hyper_2_13_chunk."time", compress_hyper_2_13_chunk.int_value, compress_hyper_2_13_chunk.float_value + Index Cond: (compress_hyper_2_13_chunk.segment_by_value > 0) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_4_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_4_chunk + Output: _hyper_1_4_chunk.segment_by_value + Filter: ((_hyper_1_4_chunk.segment_by_value > 0) AND (_hyper_1_4_chunk.int_value > 0)) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_5_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_5_chunk + Output: _hyper_1_5_chunk.segment_by_value + Filter: ((_hyper_1_5_chunk.segment_by_value > 0) AND (_hyper_1_5_chunk.int_value > 0)) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_6_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_6_chunk + Output: _hyper_1_6_chunk.segment_by_value + Filter: ((_hyper_1_6_chunk.segment_by_value > 0) AND (_hyper_1_6_chunk.int_value > 0)) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_7_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_7_chunk + Output: _hyper_1_7_chunk.segment_by_value + Filter: ((_hyper_1_7_chunk.segment_by_value > 0) AND (_hyper_1_7_chunk.int_value > 0)) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_8_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_8_chunk + Output: _hyper_1_8_chunk.segment_by_value + Filter: ((_hyper_1_8_chunk.segment_by_value > 0) AND (_hyper_1_8_chunk.int_value > 0)) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_9_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_9_chunk + Output: _hyper_1_9_chunk.segment_by_value + Filter: ((_hyper_1_9_chunk.segment_by_value > 0) AND (_hyper_1_9_chunk.int_value > 0)) + -> Partial Aggregate + Output: PARTIAL sum(_hyper_1_10_chunk.segment_by_value) + -> Seq Scan on _timescaledb_internal._hyper_1_10_chunk + Output: _hyper_1_10_chunk.segment_by_value + Filter: ((_hyper_1_10_chunk.segment_by_value > 0) AND (_hyper_1_10_chunk.int_value > 0)) +(65 rows) :EXPLAIN SELECT sum(segment_by_value) FROM testtable WHERE int_value > 0; diff --git a/tsl/test/shared/expected/transparent_decompress_chunk-15.out b/tsl/test/shared/expected/transparent_decompress_chunk-15.out index bd32d6cb8da..ceb0994b44f 100644 --- a/tsl/test/shared/expected/transparent_decompress_chunk-15.out +++ b/tsl/test/shared/expected/transparent_decompress_chunk-15.out @@ -144,14 +144,12 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id IS NOT NULL ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: (device_id IS NOT NULL) -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + -> Seq Scan on compress_hyper_X_X_chunk + Filter: (device_id IS NOT NULL) +(6 rows) :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id IS NULL ORDER BY time, device_id LIMIT 10; QUERY PLAN @@ -189,26 +187,22 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id = v0 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id = v0) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id = v0) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id < v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id < v1) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id < v1) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test expressions :PREFIX SELECT * FROM :TEST_TABLE WHERE device_id = 1 + 4 / 2 ORDER BY time, device_id LIMIT 10; @@ -224,14 +218,12 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id = length(substring(version(), 1, 3)) ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time" - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id = length("substring"(version(), 1, 3))) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time" + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id = length("substring"(version(), 1, 3))) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test segment meta pushdown -- order by column and const @@ -247,133 +239,111 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE time < '2000-01-01 1:00:00+0' ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: ("time" < 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: (_ts_meta_min_1 < 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) -(9 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: ("time" < 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) + -> Seq Scan on compress_hyper_X_X_chunk + Filter: (_ts_meta_min_1 < 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) +(7 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE time <= '2000-01-01 1:00:00+0' ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: ("time" <= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: (_ts_meta_min_1 <= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) -(9 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: ("time" <= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) + -> Seq Scan on compress_hyper_X_X_chunk + Filter: (_ts_meta_min_1 <= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) +(7 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE time >= '2000-01-01 1:00:00+0' ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: ("time" >= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: (_ts_meta_max_1 >= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) -(9 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: ("time" >= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) + -> Seq Scan on compress_hyper_X_X_chunk + Filter: (_ts_meta_max_1 >= 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) +(7 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: ("time" > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: (_ts_meta_max_1 > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) -(9 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: ("time" > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) + -> Seq Scan on compress_hyper_X_X_chunk + Filter: (_ts_meta_max_1 > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) +(7 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE '2000-01-01 1:00:00+0' < time ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: ("time" > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: (_ts_meta_max_1 > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) -(9 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: ("time" > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) + -> Seq Scan on compress_hyper_X_X_chunk + Filter: (_ts_meta_max_1 > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) +(7 rows) --pushdowns between order by and segment by columns :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE v0 < 1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: (v0 < 1) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: (v0 < 1) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE v0 < device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (v0 < device_id) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (v0 < device_id) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE device_id < v0 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (device_id < v0) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (device_id < v0) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE v1 = device_id ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (v1 = device_id) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (v1 = device_id) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) --pushdown between two order by column (not pushed down) :PREFIX SELECT * FROM :TEST_TABLE WHERE v0 = v1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit (actual rows=0 loops=1) - -> Gather Merge (actual rows=0 loops=1) - Workers Planned: 2 - Workers Launched: 2 - -> Sort (actual rows=0 loops=2) - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - Worker 0: Sort Method: quicksort - Worker 1: Sort Method: quicksort - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=2) - Filter: (v0 = v1) - Rows Removed by Filter: 8995 - -> Parallel Seq Scan on compress_hyper_X_X_chunk (actual rows=10 loops=2) -(12 rows) + -> Sort (actual rows=0 loops=1) + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + Sort Method: quicksort + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk (actual rows=0 loops=1) + Filter: (v0 = v1) + Rows Removed by Filter: 17990 + -> Seq Scan on compress_hyper_X_X_chunk (actual rows=20 loops=1) +(8 rows) --pushdown of quals on order by and segment by cols anded together :PREFIX_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' AND device_id = 1 ORDER BY time, device_id LIMIT 10; @@ -394,28 +364,24 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE time > '2000-01-01 1:00:00+0' OR device_id = 1 ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Filter: (("time" > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) OR (device_id = 1)) - -> Parallel Seq Scan on compress_hyper_X_X_chunk - Filter: ((_ts_meta_max_1 > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) OR (device_id = 1)) -(9 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Filter: (("time" > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) OR (device_id = 1)) + -> Seq Scan on compress_hyper_X_X_chunk + Filter: ((_ts_meta_max_1 > 'Fri Dec 31 17:00:00 1999 PST'::timestamp with time zone) OR (device_id = 1)) +(7 rows) --functions not yet optimized :PREFIX_NO_VERBOSE SELECT * FROM :TEST_TABLE WHERE time < now() ORDER BY time, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - Vectorized Filter: ("time" < now()) - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(8 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time", _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + Vectorized Filter: ("time" < now()) + -> Seq Scan on compress_hyper_X_X_chunk +(6 rows) -- test sort optimization interaction :PREFIX_NO_VERBOSE SELECT time FROM :TEST_TABLE ORDER BY time DESC LIMIT 10; @@ -430,13 +396,11 @@ QUERY PLAN :PREFIX_NO_VERBOSE SELECT time, device_id FROM :TEST_TABLE ORDER BY time DESC, device_id LIMIT 10; QUERY PLAN Limit - -> Gather Merge - Workers Planned: 2 - -> Sort - Sort Key: _hyper_X_X_chunk."time" DESC, _hyper_X_X_chunk.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk - -> Parallel Seq Scan on compress_hyper_X_X_chunk -(7 rows) + -> Sort + Sort Key: _hyper_X_X_chunk."time" DESC, _hyper_X_X_chunk.device_id + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk + -> Seq Scan on compress_hyper_X_X_chunk +(5 rows) :PREFIX_NO_VERBOSE SELECT time, device_id FROM :TEST_TABLE ORDER BY device_id, time DESC LIMIT 10; QUERY PLAN @@ -680,11 +644,14 @@ QUERY PLAN Sort Key: m1."time", m1.device_id -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m1 -> Seq Scan on compress_hyper_X_X_chunk - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m2 - Filter: (m1."time" = "time") - -> Index Scan using compress_hyper_X_X_chunk_device_id__ts_meta_min_1__ts_meta_idx on compress_hyper_X_X_chunk compress_hyper_X_X_chunk_1 - Index Cond: (device_id = m1.device_id) -(10 rows) + -> Memoize + Cache Key: m1."time", m1.device_id + Cache Mode: logical + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m2 + Filter: (m1."time" = "time") + -> Index Scan using compress_hyper_X_X_chunk_device_id__ts_meta_min_1__ts_meta_idx on compress_hyper_X_X_chunk compress_hyper_X_X_chunk_1 + Index Cond: (device_id = m1.device_id) +(13 rows) :PREFIX_NO_VERBOSE SELECT * @@ -698,23 +665,24 @@ FROM :TEST_TABLE m1 LIMIT 10; QUERY PLAN Limit - -> Merge Join - Merge Cond: (m1."time" = m3."time") - -> Nested Loop + -> Nested Loop + -> Gather Merge + Workers Planned: 2 -> Sort Sort Key: m1."time", m1.device_id - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m1 - -> Seq Scan on compress_hyper_X_X_chunk - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m2 - Filter: (m1."time" = "time") - -> Index Scan using compress_hyper_X_X_chunk_device_id__ts_meta_min_1__ts_meta_idx on compress_hyper_X_X_chunk compress_hyper_X_X_chunk_1 - Index Cond: (device_id = m1.device_id) - -> Sort - Sort Key: m3."time" - -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m3 - -> Seq Scan on compress_hyper_X_X_chunk compress_hyper_X_X_chunk_2 - Filter: (device_id = 3) -(17 rows) + -> Parallel Hash Join + Hash Cond: (m1."time" = m3."time") + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m1 + -> Parallel Seq Scan on compress_hyper_X_X_chunk + -> Parallel Hash + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m3 + -> Parallel Seq Scan on compress_hyper_X_X_chunk compress_hyper_X_X_chunk_2 + Filter: (device_id = 3) + -> Custom Scan (DecompressChunk) on _hyper_X_X_chunk m2 + Filter: (m1."time" = "time") + -> Index Scan using compress_hyper_X_X_chunk_device_id__ts_meta_min_1__ts_meta_idx on compress_hyper_X_X_chunk compress_hyper_X_X_chunk_1 + Index Cond: (device_id = m1.device_id) +(18 rows) RESET min_parallel_table_scan_size; :PREFIX_NO_VERBOSE diff --git a/tsl/test/sql/merge_append_partially_compressed.sql.in b/tsl/test/sql/merge_append_partially_compressed.sql.in index 81f39658d7a..a75aa16e78c 100644 --- a/tsl/test/sql/merge_append_partially_compressed.sql.in +++ b/tsl/test/sql/merge_append_partially_compressed.sql.in @@ -11,52 +11,41 @@ set enable_parallel_append to off; -- for less flaky plans set timescaledb.enable_decompression_sorted_merge = off; \set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)' -CREATE TABLE mapc_test(time timestamptz, device int, value float); -SELECT create_hypertable('mapc_test','time', create_default_indexes => false); -ALTER TABLE mapc_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); +CREATE TABLE ht_metrics_compressed(time timestamptz, device int, value float); +SELECT create_hypertable('ht_metrics_compressed','time'); +ALTER TABLE ht_metrics_compressed SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby='time'); -INSERT INTO mapc_test +INSERT INTO ht_metrics_compressed SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 second') time, -generate_series(1,10) device; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'6 hour') time, +generate_series(1,3) device; -select format('select count(*), min(time) from %s', x) from show_chunks('mapc_test') x \gexec - -SELECT compress_chunk(c) FROM show_chunks('mapc_test') c; +SELECT compress_chunk(c) FROM show_chunks('ht_metrics_compressed') c; -- make them partially compressed -INSERT INTO mapc_test +INSERT INTO ht_metrics_compressed SELECT time, device, device * 0.1 -FROM generate_series('2020-01-02'::timestamptz,'2020-01-15'::timestamptz,'4 minute') time, -generate_series(1,10) device; - -create index on mapc_test(time); - -analyze mapc_test; +FROM generate_series('2020-01-02'::timestamptz,'2020-01-18'::timestamptz,'9 hour') time, +generate_series(1,3) device; -- chunkAppend eligible queries (from tsbench) -- sort is not pushed down -:PREFIX SELECT * FROM mapc_test ORDER BY time DESC, device LIMIT 1; -:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; -:PREFIX SELECT * FROM mapc_test ORDER BY time desc limit 10; -:PREFIX SELECT * FROM mapc_test ORDER BY time_bucket('2d',time) DESC LIMIT 1; -:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; -:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; - --- index scan, no sort on top -:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; -SELECT * FROM mapc_test WHERE device = 3 ORDER BY time DESC LIMIT 1; - --- index scan, no sort on top -:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -SELECT * FROM mapc_test WHERE device = 3 ORDER BY device, time DESC LIMIT 1; - +:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time DESC, device LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('1d', time) DESC, device LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time desc limit 10; +:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY time_bucket('2d',time) DESC LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time DESC LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY time, device DESC LIMIT 1; -- index scan, no sort on top -:PREFIX SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -SELECT * FROM mapc_test WHERE device = 3 ORDER BY time, device DESC LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; -- index scan, no resorting required +SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time DESC LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; -- this uses the index and does not do sort on top +SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY device, time DESC LIMIT 1; +:PREFIX SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- this also uses the index and does not do sort on top +SELECT * FROM ht_metrics_compressed WHERE device = 3 ORDER BY time, device DESC LIMIT 1; -- not eligible for chunkAppend, but eligible for sort pushdown -:PREFIX SELECT * FROM mapc_test ORDER BY device, time DESC LIMIT 1; -- with pushdown -:PREFIX SELECT * FROM mapc_test WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM ht_metrics_compressed ORDER BY device, time DESC LIMIT 1; -- with pushdown +:PREFIX SELECT * FROM ht_metrics_compressed WHERE device IN (1,2,3) ORDER BY device, time DESC LIMIT 1; -- with pushdown CREATE TABLE test1 ( time timestamptz NOT NULL, From a51633a4064a5dbb8c0b9ad969a41575e79217df Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov <36882414+akuzm@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:17:12 +0100 Subject: [PATCH 12/12] fix --- tsl/src/nodes/decompress_chunk/qual_pushdown.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsl/src/nodes/decompress_chunk/qual_pushdown.c b/tsl/src/nodes/decompress_chunk/qual_pushdown.c index 8246f718bfb..2fbb07cbf16 100644 --- a/tsl/src/nodes/decompress_chunk/qual_pushdown.c +++ b/tsl/src/nodes/decompress_chunk/qual_pushdown.c @@ -97,7 +97,7 @@ pushdown_quals(PlannerInfo *root, CompressionSettings *settings, RelOptInfo *chu decompress_clauses = lappend(decompress_clauses, ri); } - if (context.needs_recheck) + if (context.can_pushdown && context.needs_recheck) { /* * If we managed to push down the comparison of orderby column @@ -106,7 +106,6 @@ pushdown_quals(PlannerInfo *root, CompressionSettings *settings, RelOptInfo *chu * close to 1. */ ri->norm_selec = 1; - Assert(context.can_pushdown); } } chunk_rel->baserestrictinfo = decompress_clauses;