pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: cdalxndr@yahoo.com
Subject: BUG #15139: Gin index limtied to configuration not used
Date: Fri, 30 Mar 2018 17:11:22 +0000
Message-ID: <152242988260.6322.11237886300088068445@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15139
Logged by:          Alex
Email address:      cdalxndr@yahoo.com
PostgreSQL version: 10.3
Operating system:   Windows 10
Description:        

Having the following index:
CREATE INDEX product_en_idx ON product USING GIN (lexeme) WHERE language =
'en' :: REGCONFIG;

(The column product.lexeme is of type 'tsvector')

When issuing a query from my java hibernate app, it is not using this index
(from pg log):
2018-03-30 19:43:51.902 EEST [4780] LOG:  duration: 3665.170 ms  execute
<unnamed>: /* dynamic native SQL query */ select count(*)
	from product product
	where product.lexeme @@ plainto_tsquery(cast($1 as regconfig), $2) and
product.language = cast($3 as regconfig)
2018-03-30 19:43:51.902 EEST [4780] DETAIL:  parameters: $1 = 'en', $2 =
'some query', $3 = 'en'

Removing the where from index, fixes this problem and the query runs fast:
CREATE INDEX product_lexeme_idx ON dev.product USING gin(lexeme)

The query planner should also use the first index, as it contains 'where
product.language = en'.

Note that manually running this query with inline arguments in pgadmin4
query tool, the first index is used correctly. This issue replicates only
with queries from my app.



Message-ID: <152242988260.6322.11237886300088068445@wrigleys.postgresql.org>
Permalink:  ../152242988260.6322.11237886300088068445@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/152242988260.6322.11237886300088068445@wrigleys.postgresql.org

 · 

reply

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 #15139: Gin index limtied to configuration not used
  In-Reply-To: <152242988260.6322.11237886300088068445@wrigleys.postgresql.org>
  References: <152242988260.6322.11237886300088068445@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