BUG #15136: gin index not used when using column with a where clause - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15136: gin index not used when using column with a where clause
Date
Msg-id 152235612063.6316.9977108518874961054@wrigleys.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15136
Logged by:          Improve query planner
Email address:      cdalxndr@yahoo.com
PostgreSQL version: 9.6.0
Operating system:   Windows 10
Description:

Index defined as:
CREATE INDEX product_en_idx
  ON product USING GIN (lexeme)
  WHERE language = 'en' :: REGCONFIG;

Column product.lexeme is of type tsvector, and product.language is
regconfig.

The following query doesn't use this index:
select count(*) from product p 
where p.lexeme @@ plainto_tsquery(p.language, 'text') and p.language =
'en'::regconfig

But this one does:
select count(*) from product p 
where p.lexeme @@ plainto_tsquery('en'::regconfig, 'text') and p.language =
'en'::regconfig

As language is restricted in the 'where' clause, both queries should use the
index.


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15135: Feature-Request: extend error-message if value is too long
Next
From: PG Bug reporting form
Date:
Subject: BUG #15137: X509 auth breaks in CA has extendedKeyUsage