Bug: When user-defined AM is used, the index path cannot be selected correctly

From: Quan Zongliang <quanzongliang(at)yeah(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Bug: When user-defined AM is used, the index path cannot be selected correctly
Date: 2022-08-17 01:43:54
Message-ID: f293b91d-1d46-d386-b6bb-4b06ff5c667b@yeah.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi,

1. When using extended PGroonga

CREATE EXTENSION pgroonga;

CREATE TABLE memos (
id boolean,
content varchar
);

CREATE INDEX idxA ON memos USING pgroonga (id);

2. Disable bitmapscan and seqscan:

SET enable_seqscan=off;
SET enable_indexscan=on;
SET enable_bitmapscan=off;

3. Neither ID = 'f' nor id= 't' can use the index correctly.

postgres=# explain select * from memos where id='f';
QUERY PLAN
--------------------------------------------------------------------------
Seq Scan on memos (cost=10000000000.00..10000000001.06 rows=3 width=33)
Filter: (NOT id)
(2 rows)

postgres=# explain select * from memos where id='t';
QUERY PLAN
--------------------------------------------------------------------------
Seq Scan on memos (cost=10000000000.00..10000000001.06 rows=3 width=33)
Filter: id
(2 rows)

postgres=# explain select * from memos where id>='t';
QUERY PLAN
-------------------------------------------------------------------
Index Scan using idxa on memos (cost=0.00..4.01 rows=2 width=33)
Index Cond: (id >= true)
(2 rows)

The reason is that these expressions are converted to BoolExpr and Var.
match_clause_to_indexcol does not use them to check boolean-index.

patch attached.

--
Quan Zongliang
Beijing Vastdata

Attachment Content-Type Size
indxpath.patch text/plain 574 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan S. Katz 2022-08-17 01:45:06 Re: SQL/JSON features for v15
Previous Message Andres Freund 2022-08-17 01:14:31 Re: build remaining Flex files standalone