Fix flaky Hypercore index test

Having multiple indexes that include same prefix of columns caused the
planner to sometimes pick a different index for one of the querires,
which led to different test output. Temporarily remove the alternative
index to make the test predictible.
This commit is contained in:
Erik Nordström 2024-10-18 17:42:56 +02:00 committed by Erik Nordström
parent 23b736e449
commit 132d14fe7d
2 changed files with 14 additions and 0 deletions

View File

@ -258,6 +258,10 @@ and (attname='location_id' or attname='device_id' or attname='owner_id');
-- the query should not use index-only scan on the hypestore chunk
-- (number 2) because it is not supported on segmentby indexes
--
-- first, drop one of the indexes on location_id to make the index to
-- pick predictible
drop index hypertable_location_id_include_humidity_idx;
select explain_anonymize(format($$
select location_id, count(*) into comp from %s
where location_id in (3,4,5) group by location_id
@ -646,6 +650,8 @@ $$, :'chunk1'));
-- Analyze will run the queries so we are satisfied with this right
-- now and do not run the queries separately since they can generate
-- different results depending on table contents.
-- Add back covering index on location_id
create index hypertable_location_id_include_humidity_idx on :hypertable (location_id) include (humidity);
select explain_analyze_anonymize(format($$
select location_id, avg(humidity) from %s where location_id between 5 and 10
group by location_id order by location_id

View File

@ -93,6 +93,10 @@ and (attname='location_id' or attname='device_id' or attname='owner_id');
-- the query should not use index-only scan on the hypestore chunk
-- (number 2) because it is not supported on segmentby indexes
--
-- first, drop one of the indexes on location_id to make the index to
-- pick predictible
drop index hypertable_location_id_include_humidity_idx;
select explain_anonymize(format($$
select location_id, count(*) into comp from %s
where location_id in (3,4,5) group by location_id
@ -213,6 +217,10 @@ $$, :'chunk1'));
-- Analyze will run the queries so we are satisfied with this right
-- now and do not run the queries separately since they can generate
-- different results depending on table contents.
-- Add back covering index on location_id
create index hypertable_location_id_include_humidity_idx on :hypertable (location_id) include (humidity);
select explain_analyze_anonymize(format($$
select location_id, avg(humidity) from %s where location_id between 5 and 10
group by location_id order by location_id