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

From Quan Zongliang
Subject Bug: When user-defined AM is used, the index path cannot be selected correctly
Date
Msg-id f293b91d-1d46-d386-b6bb-4b06ff5c667b@yeah.net
Whole thread Raw
Responses Re: Bug: When user-defined AM is used, the index path cannot be selected correctly
List 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

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: build remaining Flex files standalone
Next
From: "Jonathan S. Katz"
Date:
Subject: Re: SQL/JSON features for v15