BUG #16895: Multicolumn GiST index returns incomplete results
The following bug has been logged on the website:
Bug reference: 16895
Logged by: Dan Bărbulescu
Email address: dan.barbulescu@hollo.software
PostgreSQL version: 13.2
Operating system: Debian GNU/Linux 10 (buster)
Description:
CREATE EXTENSION
IF NOT EXISTS
ltree;
CREATE EXTENSION
IF NOT EXISTS
btree_gist;
CREATE TABLE
test
AS
SELECT
_ ::TEXT ::ltree AS path,
_ ::bit(4) AS flags
FROM
GENERATE_SERIES(1, 1024000) _;
-- A large-ish table is needed, the results don't usually vary by a lot
SELECT
flags,
COUNT(*)
FROM
test
GROUP BY
1
ORDER BY
1;
-- The values are evenly distributed
CREATE INDEX ON
test
USING
gist(path, flags);
-- The "offending" index
SELECT
COUNT(*)
FROM
test
WHERE
flags = '0000';
-- Reindexing sometimes produces different results. This is as much as I've
been able to narrow it down, I haven't been able to reproduce with other
data types (i.e. text instead of ltree) or shorter bit strings.