From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: cdalxndr@yahoo.com
Subject: BUG #15136: gin index not used when using column with a where clause
Date: Thu, 29 Mar 2018 20:42:00 +0000
Message-ID: <152235612063.6316.9977108518874961054@wrigleys.postgresql.org> (raw)
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, cdalxndr@yahoo.com
Subject: Re: BUG #15136: gin index not used when using column with a where clause
In-Reply-To: <152235612063.6316.9977108518874961054@wrigleys.postgresql.org>
References: <152235612063.6316.9977108518874961054@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox