Skip to content

Commit 498bcf2

Browse files
authored
Fix the batch size estimation test with no statistics (#8824)
1 parent 67ec098 commit 498bcf2

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

tsl/test/expected/columnar_scan_cost.out

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,25 @@ select count(compress_chunk(c)) from show_chunks('estimate_count') c;
235235
2
236236

237237
vacuum analyze estimate_count;
238+
\c :TEST_DBNAME :ROLE_SUPERUSER
239+
with hypertables as (
240+
select unnest(array[compressed_hypertable_id, id])
241+
from _timescaledb_catalog.hypertable
242+
where (schema_name || '.' || table_name)::regclass = 'estimate_count'::regclass)
243+
, chunks as (
244+
select (schema_name || '.' || table_name)::regclass
245+
from _timescaledb_catalog.chunk
246+
where hypertable_id in (select * from hypertables)
247+
)
248+
delete from pg_statistic
249+
where starelid in (select * from chunks)
250+
;
238251
explain (analyze, timing off, summary off, buffers off) select * from estimate_count;
239252
--- QUERY PLAN ---
240-
Append (cost=0.04..2974.00 rows=193000 width=20) (actual rows=193000.00 loops=1)
241-
-> Custom Scan (ColumnarScan) on _hyper_3_21_chunk (cost=0.04..679.00 rows=64000 width=20) (actual rows=64000.00 loops=1)
253+
Append (cost=0.04..30079.00 rows=2000000 width=20) (actual rows=193000.00 loops=1)
254+
-> Custom Scan (ColumnarScan) on _hyper_3_21_chunk (cost=0.04..10039.00 rows=1000000 width=20) (actual rows=64000.00 loops=1)
242255
-> Seq Scan on compress_hyper_4_23_chunk (cost=0.00..39.00 rows=1000 width=88) (actual rows=1000.00 loops=1)
243-
-> Custom Scan (ColumnarScan) on _hyper_3_22_chunk (cost=0.04..1330.00 rows=129000 width=20) (actual rows=129000.00 loops=1)
256+
-> Custom Scan (ColumnarScan) on _hyper_3_22_chunk (cost=0.04..10040.00 rows=1000000 width=20) (actual rows=129000.00 loops=1)
244257
-> Seq Scan on compress_hyper_4_24_chunk (cost=0.00..40.00 rows=1000 width=88) (actual rows=1000.00 loops=1)
245258

246259
-- Test a high-cardinality orderby column

tsl/test/sql/columnar_scan_cost.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,24 @@ from generate_series('2025-01-01'::timestamptz,'2025-01-03','15 min') t,
135135
;
136136

137137
select count(compress_chunk(c)) from show_chunks('estimate_count') c;
138+
138139
vacuum analyze estimate_count;
139140

141+
\c :TEST_DBNAME :ROLE_SUPERUSER
142+
143+
with hypertables as (
144+
select unnest(array[compressed_hypertable_id, id])
145+
from _timescaledb_catalog.hypertable
146+
where (schema_name || '.' || table_name)::regclass = 'estimate_count'::regclass)
147+
, chunks as (
148+
select (schema_name || '.' || table_name)::regclass
149+
from _timescaledb_catalog.chunk
150+
where hypertable_id in (select * from hypertables)
151+
)
152+
delete from pg_statistic
153+
where starelid in (select * from chunks)
154+
;
155+
140156
explain (analyze, timing off, summary off, buffers off) select * from estimate_count;
141157

142158
-- Test a high-cardinality orderby column

0 commit comments

Comments
 (0)