From: Tom Lane <tgl@sss.pgh.pa.us>
To: grau.fran@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14518: FTS index not triggered when using function to provide the tsquery
Date: Fri, 27 Jan 2017 08:53:51 -0500
Message-ID: <27964.1485525231@sss.pgh.pa.us> (raw)
In-Reply-To: <20170127103939.1431.54363@wrigleys.postgresql.org>
References: <20170127103939.1431.54363@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
grau.fran@gmail.com writes:
> But I need to run the query through a function to generate a custom tsquery
> sometimes. So if I run:
> SELECT pub.publication_id
> FROM publication pub
> WHERE
> pub.fts @@ x_get_tsquery('Omnis')
> "Seq Scan on publication pub (cost=0.00..5939.89 rows=50 width=8)"
> " Filter: (fts @@ x_get_tsquery('Omnis'::text))"
> As you can see it uses a sequential scan... not good.
Most likely you've marked that function volatile (or allowed it to be so
marked by default). That disables using it in an index condition,
because the planner has to assume that the function's result might change
for every row. You need to mark it stable or immutable instead, per
https://www.postgresql.org/docs/devel/static/xfunc-volatility.html
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: tgl@sss.pgh.pa.us, grau.fran@gmail.com
Subject: Re: BUG #14518: FTS index not triggered when using function to provide the tsquery
In-Reply-To: <27964.1485525231@sss.pgh.pa.us>
References: <20170127103939.1431.54363@wrigleys.postgresql.org> <27964.1485525231@sss.pgh.pa.us>
* 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