Skip to content

Commit 672808f

Browse files
authored
Stabilie the compression test (#8213)
Use the plan settings more systematically, and use a more selective condition for index scan.
1 parent 47e1f8b commit 672808f

File tree

2 files changed

+49
-87
lines changed

2 files changed

+49
-87
lines changed

tsl/test/expected/compression.out

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,35 +1755,18 @@ SELECT compress_chunk(i) FROM show_chunks('f_sensor_data') i;
17551755

17561756
VACUUM ANALYZE f_sensor_data;
17571757
-- Encourage use of parallel plans
1758+
SET max_parallel_workers_per_gather = 4;
1759+
SET min_parallel_index_scan_size = 0;
1760+
SET min_parallel_table_scan_size = 0;
17581761
SET parallel_setup_cost = 0;
17591762
SET parallel_tuple_cost = 0;
1760-
SET min_parallel_table_scan_size TO '0';
1761-
\set explain 'EXPLAIN (VERBOSE, COSTS OFF)'
1762-
SHOW min_parallel_table_scan_size;
1763-
min_parallel_table_scan_size
1764-
------------------------------
1765-
0
1766-
(1 row)
1767-
17681763
SHOW max_parallel_workers;
17691764
max_parallel_workers
17701765
----------------------
17711766
8
17721767
(1 row)
17731768

1774-
SHOW max_parallel_workers_per_gather;
1775-
max_parallel_workers_per_gather
1776-
---------------------------------
1777-
2
1778-
(1 row)
1779-
1780-
SET max_parallel_workers_per_gather = 4;
1781-
SHOW max_parallel_workers_per_gather;
1782-
max_parallel_workers_per_gather
1783-
---------------------------------
1784-
4
1785-
(1 row)
1786-
1769+
\set explain 'EXPLAIN (VERBOSE, COSTS OFF)'
17871770
-- We disable enable_parallel_append here to ensure
17881771
-- that we create the same query plan in all PG 14.X versions
17891772
SET enable_parallel_append = false;
@@ -1805,24 +1788,19 @@ SELECT sum(cpu) FROM f_sensor_data;
18051788
Output: compress_hyper_38_74_chunk._ts_meta_count, compress_hyper_38_74_chunk.sensor_id, compress_hyper_38_74_chunk._ts_meta_min_1, compress_hyper_38_74_chunk._ts_meta_max_1, compress_hyper_38_74_chunk."time", compress_hyper_38_74_chunk.cpu, compress_hyper_38_74_chunk.temperature
18061789
(12 rows)
18071790

1808-
-- Encourage use of Index Scan
1809-
SET enable_seqscan = false;
1810-
SET enable_indexscan = true;
1811-
SET min_parallel_index_scan_size = 0;
1812-
SET min_parallel_table_scan_size = 0;
18131791
CREATE INDEX ON f_sensor_data (time, sensor_id);
18141792
:explain
1815-
SELECT * FROM f_sensor_data WHERE sensor_id > 100;
1793+
SELECT * FROM f_sensor_data WHERE sensor_id > 1000;
18161794
QUERY PLAN
18171795
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18181796
Gather
18191797
Output: _hyper_37_73_chunk."time", _hyper_37_73_chunk.sensor_id, _hyper_37_73_chunk.cpu, _hyper_37_73_chunk.temperature
1820-
Workers Planned: 3
1798+
Workers Planned: 2
18211799
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_37_73_chunk
18221800
Output: _hyper_37_73_chunk."time", _hyper_37_73_chunk.sensor_id, _hyper_37_73_chunk.cpu, _hyper_37_73_chunk.temperature
18231801
-> Parallel Index Scan using compress_hyper_38_74_chunk_sensor_id__ts_meta_min_1__ts_met_idx on _timescaledb_internal.compress_hyper_38_74_chunk
18241802
Output: compress_hyper_38_74_chunk._ts_meta_count, compress_hyper_38_74_chunk.sensor_id, compress_hyper_38_74_chunk._ts_meta_min_1, compress_hyper_38_74_chunk._ts_meta_max_1, compress_hyper_38_74_chunk."time", compress_hyper_38_74_chunk.cpu, compress_hyper_38_74_chunk.temperature
1825-
Index Cond: (compress_hyper_38_74_chunk.sensor_id > 100)
1803+
Index Cond: (compress_hyper_38_74_chunk.sensor_id > 1000)
18261804
(8 rows)
18271805

18281806
RESET enable_parallel_append;
@@ -1841,26 +1819,29 @@ ORDER BY
18411819
VACUUM ANALYZE f_sensor_data;
18421820
:explain
18431821
SELECT sum(cpu) FROM f_sensor_data;
1844-
QUERY PLAN
1845-
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1822+
QUERY PLAN
1823+
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18461824
Finalize Aggregate
18471825
Output: sum(_hyper_37_73_chunk.cpu)
1848-
-> Append
1849-
-> Custom Scan (VectorAgg)
1850-
Output: (PARTIAL sum(_hyper_37_73_chunk.cpu))
1851-
Grouping Policy: all compressed batches
1852-
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_37_73_chunk
1853-
Output: _hyper_37_73_chunk.cpu
1854-
-> Seq Scan on _timescaledb_internal.compress_hyper_38_74_chunk
1855-
Output: compress_hyper_38_74_chunk._ts_meta_count, compress_hyper_38_74_chunk.sensor_id, compress_hyper_38_74_chunk._ts_meta_min_1, compress_hyper_38_74_chunk._ts_meta_max_1, compress_hyper_38_74_chunk."time", compress_hyper_38_74_chunk.cpu, compress_hyper_38_74_chunk.temperature
1856-
-> Partial Aggregate
1857-
Output: PARTIAL sum(_hyper_37_73_chunk.cpu)
1858-
-> Seq Scan on _timescaledb_internal._hyper_37_73_chunk
1859-
Output: _hyper_37_73_chunk.cpu
1860-
(14 rows)
1826+
-> Gather
1827+
Output: (PARTIAL sum(_hyper_37_73_chunk.cpu))
1828+
Workers Planned: 4
1829+
-> Parallel Append
1830+
-> Custom Scan (VectorAgg)
1831+
Output: (PARTIAL sum(_hyper_37_73_chunk.cpu))
1832+
Grouping Policy: all compressed batches
1833+
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_37_73_chunk
1834+
Output: _hyper_37_73_chunk.cpu
1835+
-> Parallel Seq Scan on _timescaledb_internal.compress_hyper_38_74_chunk
1836+
Output: compress_hyper_38_74_chunk._ts_meta_count, compress_hyper_38_74_chunk.sensor_id, compress_hyper_38_74_chunk._ts_meta_min_1, compress_hyper_38_74_chunk._ts_meta_max_1, compress_hyper_38_74_chunk."time", compress_hyper_38_74_chunk.cpu, compress_hyper_38_74_chunk.temperature
1837+
-> Partial Aggregate
1838+
Output: PARTIAL sum(_hyper_37_73_chunk.cpu)
1839+
-> Parallel Seq Scan on _timescaledb_internal._hyper_37_73_chunk
1840+
Output: _hyper_37_73_chunk.cpu
1841+
(17 rows)
18611842

18621843
:explain
1863-
SELECT * FROM f_sensor_data WHERE sensor_id > 100;
1844+
SELECT * FROM f_sensor_data WHERE sensor_id > 1000;
18641845
QUERY PLAN
18651846
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18661847
Gather
@@ -1869,13 +1850,13 @@ SELECT * FROM f_sensor_data WHERE sensor_id > 100;
18691850
-> Parallel Append
18701851
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_37_73_chunk
18711852
Output: _hyper_37_73_chunk."time", _hyper_37_73_chunk.sensor_id, _hyper_37_73_chunk.cpu, _hyper_37_73_chunk.temperature
1872-
Filter: (_hyper_37_73_chunk.sensor_id > 100)
1853+
Filter: (_hyper_37_73_chunk.sensor_id > 1000)
18731854
-> Parallel Index Scan using compress_hyper_38_74_chunk_sensor_id__ts_meta_min_1__ts_met_idx on _timescaledb_internal.compress_hyper_38_74_chunk
18741855
Output: compress_hyper_38_74_chunk._ts_meta_count, compress_hyper_38_74_chunk.sensor_id, compress_hyper_38_74_chunk._ts_meta_min_1, compress_hyper_38_74_chunk._ts_meta_max_1, compress_hyper_38_74_chunk."time", compress_hyper_38_74_chunk.cpu, compress_hyper_38_74_chunk.temperature
1875-
Index Cond: (compress_hyper_38_74_chunk.sensor_id > 100)
1876-
-> Parallel Index Scan using _hyper_37_73_chunk_f_sensor_data_time_sensor_id_idx on _timescaledb_internal._hyper_37_73_chunk
1856+
Index Cond: (compress_hyper_38_74_chunk.sensor_id > 1000)
1857+
-> Parallel Seq Scan on _timescaledb_internal._hyper_37_73_chunk
18771858
Output: _hyper_37_73_chunk."time", _hyper_37_73_chunk.sensor_id, _hyper_37_73_chunk.cpu, _hyper_37_73_chunk.temperature
1878-
Index Cond: (_hyper_37_73_chunk.sensor_id > 100)
1859+
Filter: (_hyper_37_73_chunk.sensor_id > 1000)
18791860
(13 rows)
18801861

18811862
-- Test non-partial paths below append are not executed multiple times
@@ -1961,34 +1942,25 @@ SELECT * FROM ht_metrics_partially_compressed ORDER BY time DESC, device LIMIT 1
19611942
QUERY PLAN
19621943
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
19631944
Limit
1964-
Output: ht_metrics_partially_compressed."time", ht_metrics_partially_compressed.device, ht_metrics_partially_compressed.value
1965-
-> Custom Scan (ChunkAppend) on public.ht_metrics_partially_compressed
1966-
Output: ht_metrics_partially_compressed."time", ht_metrics_partially_compressed.device, ht_metrics_partially_compressed.value
1967-
Order: ht_metrics_partially_compressed."time" DESC, ht_metrics_partially_compressed.device
1968-
Startup Exclusion: false
1969-
Runtime Exclusion: false
1945+
Output: _hyper_41_78_chunk."time", _hyper_41_78_chunk.device, _hyper_41_78_chunk.value
1946+
-> Gather Merge
1947+
Output: _hyper_41_78_chunk."time", _hyper_41_78_chunk.device, _hyper_41_78_chunk.value
1948+
Workers Planned: 2
19701949
-> Sort
19711950
Output: _hyper_41_78_chunk."time", _hyper_41_78_chunk.device, _hyper_41_78_chunk.value
19721951
Sort Key: _hyper_41_78_chunk."time" DESC, _hyper_41_78_chunk.device
1973-
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_41_78_chunk
1974-
Output: _hyper_41_78_chunk."time", _hyper_41_78_chunk.device, _hyper_41_78_chunk.value
1975-
-> Seq Scan on _timescaledb_internal.compress_hyper_42_80_chunk
1976-
Output: compress_hyper_42_80_chunk._ts_meta_count, compress_hyper_42_80_chunk.device, compress_hyper_42_80_chunk._ts_meta_min_1, compress_hyper_42_80_chunk._ts_meta_max_1, compress_hyper_42_80_chunk."time", compress_hyper_42_80_chunk.value
1977-
-> Merge Append
1978-
Sort Key: _hyper_41_77_chunk."time" DESC, _hyper_41_77_chunk.device
1979-
-> Sort
1980-
Output: _hyper_41_77_chunk."time", _hyper_41_77_chunk.device, _hyper_41_77_chunk.value
1981-
Sort Key: _hyper_41_77_chunk."time" DESC, _hyper_41_77_chunk.device
1952+
-> Parallel Append
1953+
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_41_78_chunk
1954+
Output: _hyper_41_78_chunk."time", _hyper_41_78_chunk.device, _hyper_41_78_chunk.value
1955+
-> Parallel Seq Scan on _timescaledb_internal.compress_hyper_42_80_chunk
1956+
Output: compress_hyper_42_80_chunk._ts_meta_count, compress_hyper_42_80_chunk.device, compress_hyper_42_80_chunk._ts_meta_min_1, compress_hyper_42_80_chunk._ts_meta_max_1, compress_hyper_42_80_chunk."time", compress_hyper_42_80_chunk.value
19821957
-> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_41_77_chunk
19831958
Output: _hyper_41_77_chunk."time", _hyper_41_77_chunk.device, _hyper_41_77_chunk.value
1984-
-> Seq Scan on _timescaledb_internal.compress_hyper_42_79_chunk
1959+
-> Parallel Seq Scan on _timescaledb_internal.compress_hyper_42_79_chunk
19851960
Output: compress_hyper_42_79_chunk._ts_meta_count, compress_hyper_42_79_chunk.device, compress_hyper_42_79_chunk._ts_meta_min_1, compress_hyper_42_79_chunk._ts_meta_max_1, compress_hyper_42_79_chunk."time", compress_hyper_42_79_chunk.value
1986-
-> Sort
1987-
Output: _hyper_41_77_chunk."time", _hyper_41_77_chunk.device, _hyper_41_77_chunk.value
1988-
Sort Key: _hyper_41_77_chunk."time" DESC, _hyper_41_77_chunk.device
1989-
-> Seq Scan on _timescaledb_internal._hyper_41_77_chunk
1961+
-> Parallel Seq Scan on _timescaledb_internal._hyper_41_77_chunk
19901962
Output: _hyper_41_77_chunk."time", _hyper_41_77_chunk.device, _hyper_41_77_chunk.value
1991-
(28 rows)
1963+
(19 rows)
19921964

19931965
-- Test parameter change on rescan
19941966
-- issue 6069

tsl/test/sql/compression.sql

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -782,18 +782,14 @@ SELECT compress_chunk(i) FROM show_chunks('f_sensor_data') i;
782782
VACUUM ANALYZE f_sensor_data;
783783

784784
-- Encourage use of parallel plans
785+
SET max_parallel_workers_per_gather = 4;
786+
SET min_parallel_index_scan_size = 0;
787+
SET min_parallel_table_scan_size = 0;
785788
SET parallel_setup_cost = 0;
786789
SET parallel_tuple_cost = 0;
787-
SET min_parallel_table_scan_size TO '0';
788-
789-
\set explain 'EXPLAIN (VERBOSE, COSTS OFF)'
790-
791-
SHOW min_parallel_table_scan_size;
792790
SHOW max_parallel_workers;
793-
SHOW max_parallel_workers_per_gather;
794791

795-
SET max_parallel_workers_per_gather = 4;
796-
SHOW max_parallel_workers_per_gather;
792+
\set explain 'EXPLAIN (VERBOSE, COSTS OFF)'
797793

798794
-- We disable enable_parallel_append here to ensure
799795
-- that we create the same query plan in all PG 14.X versions
@@ -802,16 +798,10 @@ SET enable_parallel_append = false;
802798
:explain
803799
SELECT sum(cpu) FROM f_sensor_data;
804800

805-
-- Encourage use of Index Scan
806-
807-
SET enable_seqscan = false;
808-
SET enable_indexscan = true;
809-
SET min_parallel_index_scan_size = 0;
810-
SET min_parallel_table_scan_size = 0;
811-
812801
CREATE INDEX ON f_sensor_data (time, sensor_id);
802+
813803
:explain
814-
SELECT * FROM f_sensor_data WHERE sensor_id > 100;
804+
SELECT * FROM f_sensor_data WHERE sensor_id > 1000;
815805

816806
RESET enable_parallel_append;
817807

@@ -835,7 +825,7 @@ VACUUM ANALYZE f_sensor_data;
835825
SELECT sum(cpu) FROM f_sensor_data;
836826

837827
:explain
838-
SELECT * FROM f_sensor_data WHERE sensor_id > 100;
828+
SELECT * FROM f_sensor_data WHERE sensor_id > 1000;
839829

840830

841831
-- Test non-partial paths below append are not executed multiple times

0 commit comments

Comments
 (0)