From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim McDonald <Jim@mcdee.net>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #12644: Planner fails to use available index with anything other than default operator
Date: Sat, 24 Jan 2015 17:23:36 -0500
Message-ID: <23433.1422138216@sss.pgh.pa.us> (raw)
In-Reply-To: <54C3D40D.80205@mcdee.net>
References: <20150123181759.32669.55573@wrigleys.postgresql.org>
<16692.1422111691@sss.pgh.pa.us>
<54C3D40D.80205@mcdee.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Jim McDonald <Jim@mcdee.net> writes:
> On 24/01/2015 15:01, Tom Lane wrote:
>> Nope, this doesn't work, never has, and will not in the foreseeable
>> future. Index access is defined in terms of operators, not other
>> ways to access the same function; see
> Fair enough. As a workaround in the meantime is it possible to create a
> custom operator that is recognised as being in the correct family/class
> so that it will use the index?
Not really, I'm afraid. In the abstract maybe you could add such an
operator to an existing operator class; but in practice this will fall
foul of the unique indexes on pg_amop, which insist that there be
at most one operator per strategy per opclass.
However, there's more than one way to skin a cat. I think you could
probably define such an operator that references an inlineable SQL
function that expands to the desired underlying operator, along the
lines of
create function my_jsonb_exists(jsonb, text) returns bool as
'select $1 ? $2' language sql immutable;
create operator ### ( procedure = my_jsonb_exists, ...
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, Jim@mcdee.net
Subject: Re: BUG #12644: Planner fails to use available index with anything other than default operator
In-Reply-To: <23433.1422138216@sss.pgh.pa.us>
References: <20150123181759.32669.55573@wrigleys.postgresql.org> <16692.1422111691@sss.pgh.pa.us> <54C3D40D.80205@mcdee.net> <23433.1422138216@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