Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tsl/src/nodes/columnar_scan/columnar_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,19 @@ columnar_scan_path_create(PlannerInfo *root, const CompressionInfo *compression_
path->custom_path.path.param_info = NULL;
}

path->custom_path.flags = 0;
/*
* Setting this flags means that Postgres can change the result targetlist
* after the plan creation. This node can cope with this because it performs
* the usual Postgres projection to produce the result tuple from the scan
* tuple. The decompression-specific code works before that, and produces
* the scan tuple based on the compressed tuple. The scan tuple descriptor
* is based either on custom_scan_tlist or scanrelid, and the decompression
* map is based on the compressed tuple, so they are not dependent on the
* result targetlist, and we can allow it to be changed later. This allows
* us to avoid a separate Result node, for a small performance saving.
*/
path->custom_path.flags = CUSTOMPATH_SUPPORT_PROJECTION;

path->custom_path.methods = &columnar_scan_path_methods;
path->batch_sorted_merge = false;

Expand Down
91 changes: 41 additions & 50 deletions tsl/test/expected/compress_sort_transform.out
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,25 @@ order by 1 limit 1;
Order: time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time")
-> Merge Append (actual rows=1.00 loops=1)
Sort Key: (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (actual rows=1.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=3.00 loops=1)
Sort Key: compress_hyper_2_4_chunk._ts_meta_min_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_4_chunk (actual rows=3.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=3.00 loops=1)
Sort Key: compress_hyper_2_4_chunk._ts_meta_min_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_4_chunk (actual rows=3.00 loops=1)
-> Index Scan Backward using _hyper_1_1_chunk_ht_metrics_partially_compressed_time_idx on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Merge Append (never executed)
Sort Key: (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_2_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_5_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_5_chunk (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_2_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_5_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_5_chunk (never executed)
-> Index Scan Backward using _hyper_1_2_chunk_ht_metrics_partially_compressed_time_idx on _hyper_1_2_chunk (never executed)
-> Merge Append (never executed)
Sort Key: (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_3_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_6_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_6_chunk (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_3_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_6_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_6_chunk (never executed)
-> Index Scan Backward using _hyper_1_3_chunk_ht_metrics_partially_compressed_time_idx on _hyper_1_3_chunk (never executed)

-- Ordering by time_bucket, but it's not in the SELECT list.
Expand All @@ -261,28 +258,25 @@ order by time_bucket('1 minute', time) limit 1;
Order: time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time")
-> Merge Append (actual rows=1.00 loops=1)
Sort Key: (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (actual rows=1.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=3.00 loops=1)
Sort Key: compress_hyper_2_4_chunk._ts_meta_min_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_4_chunk (actual rows=3.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=3.00 loops=1)
Sort Key: compress_hyper_2_4_chunk._ts_meta_min_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_4_chunk (actual rows=3.00 loops=1)
-> Index Scan Backward using _hyper_1_1_chunk_ht_metrics_partially_compressed_time_idx on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Merge Append (never executed)
Sort Key: (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_2_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_5_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_5_chunk (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_2_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_5_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_5_chunk (never executed)
-> Index Scan Backward using _hyper_1_2_chunk_ht_metrics_partially_compressed_time_idx on _hyper_1_2_chunk (never executed)
-> Merge Append (never executed)
Sort Key: (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_3_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_6_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_6_chunk (never executed)
-> Custom Scan (ColumnarScan) on _hyper_1_3_chunk (never executed)
-> Sort (never executed)
Sort Key: compress_hyper_2_6_chunk._ts_meta_min_1
-> Seq Scan on compress_hyper_2_6_chunk (never executed)
-> Index Scan Backward using _hyper_1_3_chunk_ht_metrics_partially_compressed_time_idx on _hyper_1_3_chunk (never executed)

-- Ordering in compressed data order.
Expand All @@ -293,32 +287,29 @@ order by device, time_bucket('1 minute', time) limit 1;
Limit (actual rows=1.00 loops=1)
-> Merge Append (actual rows=1.00 loops=1)
Sort Key: ht_metrics_partially_compressed.device, (time_bucket('@ 1 min'::interval, ht_metrics_partially_compressed."time"))
-> Result (actual rows=1.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_min_1, compress_hyper_2_4_chunk._ts_meta_max_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_4_chunk (actual rows=3.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_1_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: compress_hyper_2_4_chunk.device, compress_hyper_2_4_chunk._ts_meta_min_1, compress_hyper_2_4_chunk._ts_meta_max_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_4_chunk (actual rows=3.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: _hyper_1_1_chunk.device, (time_bucket('@ 1 min'::interval, _hyper_1_1_chunk."time"))
Sort Method: top-N heapsort
-> Seq Scan on _hyper_1_1_chunk (actual rows=960.00 loops=1)
-> Result (actual rows=1.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_2_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_min_1, compress_hyper_2_5_chunk._ts_meta_max_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_5_chunk (actual rows=3.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_2_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: compress_hyper_2_5_chunk.device, compress_hyper_2_5_chunk._ts_meta_min_1, compress_hyper_2_5_chunk._ts_meta_max_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_5_chunk (actual rows=3.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: _hyper_1_2_chunk.device, (time_bucket('@ 1 min'::interval, _hyper_1_2_chunk."time"))
Sort Method: top-N heapsort
-> Seq Scan on _hyper_1_2_chunk (actual rows=1008.00 loops=1)
-> Result (actual rows=1.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_3_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_min_1, compress_hyper_2_6_chunk._ts_meta_max_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_6_chunk (actual rows=3.00 loops=1)
-> Custom Scan (ColumnarScan) on _hyper_1_3_chunk (actual rows=1.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: compress_hyper_2_6_chunk.device, compress_hyper_2_6_chunk._ts_meta_min_1, compress_hyper_2_6_chunk._ts_meta_max_1
Sort Method: quicksort
-> Seq Scan on compress_hyper_2_6_chunk (actual rows=3.00 loops=1)
-> Sort (actual rows=1.00 loops=1)
Sort Key: _hyper_1_3_chunk.device, (time_bucket('@ 1 min'::interval, _hyper_1_3_chunk."time"))
Sort Method: top-N heapsort
Expand Down
20 changes: 9 additions & 11 deletions tsl/test/expected/compression_sorted_merge.out
Original file line number Diff line number Diff line change
Expand Up @@ -1339,19 +1339,17 @@ set timescaledb.debug_require_batch_sorted_merge to 'force';
:PREFIX
SELECT "time","hin"::text,"model"::text,"block"::text,"message_name"::text,"signal_name"::text,"signal_numeric_value","signal_string_value"::text FROM :chunk_table_bugtab ORDER BY "time" DESC;
--- QUERY PLAN ---
Result (actual rows=1.00 loops=1)
Custom Scan (ColumnarScan) on _timescaledb_internal._hyper_11_23_chunk (actual rows=1.00 loops=1)
Output: _hyper_11_23_chunk."time", (_hyper_11_23_chunk.hin)::text, (_hyper_11_23_chunk.model)::text, (_hyper_11_23_chunk.block)::text, (_hyper_11_23_chunk.message_name)::text, (_hyper_11_23_chunk.signal_name)::text, _hyper_11_23_chunk.signal_numeric_value, (_hyper_11_23_chunk.signal_string_value)::text
-> Custom Scan (ColumnarScan) on _timescaledb_internal._hyper_11_23_chunk (actual rows=1.00 loops=1)
Output: _hyper_11_23_chunk."time", _hyper_11_23_chunk.hin, _hyper_11_23_chunk.model, _hyper_11_23_chunk.block, _hyper_11_23_chunk.message_name, _hyper_11_23_chunk.signal_name, _hyper_11_23_chunk.signal_numeric_value, _hyper_11_23_chunk.signal_string_value
Batch Sorted Merge: true
Reverse: true
Bulk Decompression: false
-> Sort (actual rows=1.00 loops=1)
Batch Sorted Merge: true
Reverse: true
Bulk Decompression: false
-> Sort (actual rows=1.00 loops=1)
Output: compress_hyper_12_24_chunk._ts_meta_count, compress_hyper_12_24_chunk.hin, compress_hyper_12_24_chunk.signal_name, compress_hyper_12_24_chunk._ts_meta_min_1, compress_hyper_12_24_chunk._ts_meta_max_1, compress_hyper_12_24_chunk."time", compress_hyper_12_24_chunk.model, compress_hyper_12_24_chunk.block, compress_hyper_12_24_chunk.message_name, compress_hyper_12_24_chunk.signal_numeric_value, compress_hyper_12_24_chunk.signal_string_value
Sort Key: compress_hyper_12_24_chunk._ts_meta_max_1 DESC
Sort Method: quicksort
-> Seq Scan on _timescaledb_internal.compress_hyper_12_24_chunk (actual rows=1.00 loops=1)
Output: compress_hyper_12_24_chunk._ts_meta_count, compress_hyper_12_24_chunk.hin, compress_hyper_12_24_chunk.signal_name, compress_hyper_12_24_chunk._ts_meta_min_1, compress_hyper_12_24_chunk._ts_meta_max_1, compress_hyper_12_24_chunk."time", compress_hyper_12_24_chunk.model, compress_hyper_12_24_chunk.block, compress_hyper_12_24_chunk.message_name, compress_hyper_12_24_chunk.signal_numeric_value, compress_hyper_12_24_chunk.signal_string_value
Sort Key: compress_hyper_12_24_chunk._ts_meta_max_1 DESC
Sort Method: quicksort
-> Seq Scan on _timescaledb_internal.compress_hyper_12_24_chunk (actual rows=1.00 loops=1)
Output: compress_hyper_12_24_chunk._ts_meta_count, compress_hyper_12_24_chunk.hin, compress_hyper_12_24_chunk.signal_name, compress_hyper_12_24_chunk._ts_meta_min_1, compress_hyper_12_24_chunk._ts_meta_max_1, compress_hyper_12_24_chunk."time", compress_hyper_12_24_chunk.model, compress_hyper_12_24_chunk.block, compress_hyper_12_24_chunk.message_name, compress_hyper_12_24_chunk.signal_numeric_value, compress_hyper_12_24_chunk.signal_string_value

SELECT "time","hin"::text,"model"::text,"block"::text,"message_name"::text,"signal_name"::text,"signal_numeric_value","signal_string_value"::text FROM :chunk_table_bugtab ORDER BY "time" DESC;
time | hin | model | block | message_name | signal_name | signal_numeric_value | signal_string_value
Expand Down
Loading
Loading