BUG #15136: gin index not used when using column with a where clause

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: cdalxndr(at)yahoo(dot)com
Subject: BUG #15136: gin index not used when using column with a where clause
Date: 2018-03-29 20:42:00
Message-ID: 152235612063.6316.9977108518874961054@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15136
Logged by: Improve query planner
Email address: cdalxndr(at)yahoo(dot)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.

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2018-03-30 13:11:29 BUG #15137: X509 auth breaks in CA has extendedKeyUsage
Previous Message PG Bug reporting form 2018-03-29 15:18:22 BUG #15135: Feature-Request: extend error-message if value is too long