Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 62097a4

Browse files
committed
Fix selectivity estimation @> (anymultirange, anyrange) operator
Attempt to get selectivity estimation for @> (anymultirange, anyrange) operator caused an error in buildfarm, because this operator was missed in switch() of calc_hist_selectivity(). Fix that and also make regression tests reliably check that selectivity estimation for (multi)ranges doesn't fall. Previously, whether we test selectivity estimation for (multi)ranges depended on whether autovacuum managed to gather concurrently to the test. Reported-by: Michael Paquier Discussion: https://postgr.es/m/X%2BwmgjRItuvHNBeV%40paquier.xyz
1 parent 860fe27 commit 62097a4

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

src/backend/utils/adt/multirangetypes_selfuncs.c

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ calc_hist_selectivity(TypeCacheEntry *typcache, VariableStatData *vardata,
649649

650650
case OID_MULTIRANGE_RANGE_CONTAINED_OP:
651651
case OID_MULTIRANGE_MULTIRANGE_CONTAINED_OP:
652+
case OID_RANGE_MULTIRANGE_CONTAINED_OP:
652653
if (const_lower.infinite)
653654
{
654655
/*

src/test/regress/expected/multirangetypes.out

+5
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,11 @@ insert into test_multirange_gist select int4multirange(int4range(g, g+10000)) fr
22272227
insert into test_multirange_gist select int4multirange(int4range(NULL, g*10, '(]'), int4range(g*10, g*20, '(]')) from generate_series(1,100) g;
22282228
insert into test_multirange_gist select int4multirange(int4range(g*10, g*20, '(]'), int4range(g*20, NULL, '(]')) from generate_series(1,100) g;
22292229
create index test_mulrirange_gist_idx on test_multirange_gist using gist (mr);
2230+
-- test statistics and selectivity estimation as well
2231+
--
2232+
-- We don't check the accuracy of selectivity estimation, but at least check
2233+
-- it doesn't fall.
2234+
analyze test_multirange_gist;
22302235
-- first, verify non-indexed results
22312236
SET enable_seqscan = t;
22322237
SET enable_indexscan = f;

src/test/regress/expected/rangetypes.out

+5
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,11 @@ insert into test_range_gist select 'empty'::int4range from generate_series(1,500
792792
insert into test_range_gist select int4range(NULL,g*10,'(]') from generate_series(1,100) g;
793793
insert into test_range_gist select int4range(g*10,NULL,'(]') from generate_series(1,100) g;
794794
insert into test_range_gist select int4range(g, g+10) from generate_series(1,2000) g;
795+
-- test statistics and selectivity estimation as well
796+
--
797+
-- We don't check the accuracy of selectivity estimation, but at least check
798+
-- it doesn't fall.
799+
analyze test_range_gist;
795800
-- first, verify non-indexed results
796801
SET enable_seqscan = t;
797802
SET enable_indexscan = f;

src/test/regress/sql/multirangetypes.sql

+6
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ insert into test_multirange_gist select int4multirange(int4range(NULL, g*10, '(]
423423
insert into test_multirange_gist select int4multirange(int4range(g*10, g*20, '(]'), int4range(g*20, NULL, '(]')) from generate_series(1,100) g;
424424
create index test_mulrirange_gist_idx on test_multirange_gist using gist (mr);
425425

426+
-- test statistics and selectivity estimation as well
427+
--
428+
-- We don't check the accuracy of selectivity estimation, but at least check
429+
-- it doesn't fall.
430+
analyze test_multirange_gist;
431+
426432
-- first, verify non-indexed results
427433
SET enable_seqscan = t;
428434
SET enable_indexscan = f;

src/test/regress/sql/rangetypes.sql

+6
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ insert into test_range_gist select int4range(NULL,g*10,'(]') from generate_serie
216216
insert into test_range_gist select int4range(g*10,NULL,'(]') from generate_series(1,100) g;
217217
insert into test_range_gist select int4range(g, g+10) from generate_series(1,2000) g;
218218

219+
-- test statistics and selectivity estimation as well
220+
--
221+
-- We don't check the accuracy of selectivity estimation, but at least check
222+
-- it doesn't fall.
223+
analyze test_range_gist;
224+
219225
-- first, verify non-indexed results
220226
SET enable_seqscan = t;
221227
SET enable_indexscan = f;

0 commit comments

Comments
 (0)