From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Kevin Grittner <kgrittn(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers\(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: No longer possible to query catalogs for index capabilities? |
Date: | 2016-08-12 19:37:09 |
Message-ID: | 874m6pol1i.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> distance_orderable now returns true/false depending on the opclass,
>> not just on the amcanorderbyop field. In order to do this, I've
>> added an optional amproperty function to the AM api, which if it
>> exists, gets first dibs on all property calls so it can override the
>> result as it sees fit.
Tom> Hmm, seems like for that case, it'd be easier to look into pg_amop
Tom> and see if the opclass has any suitably-marked operators.
I thought about that, but it seemed like it could get painful. The
planner is working forwards from a known operator and matching it
against the index column, whereas we'd have to work backwards from the
opfamily, and there's no good existing index for this; in the presence
of binary-compatible types, I don't think even amoplefttype can be
assumed (e.g. a varchar column can be ordered by pg_trgm's <-> operator
which is declared for text). So it'd have to be the equivalent of:
get index column's opclass oid
look it up in pg_opclass to get opfamily
for r in select * from pg_amop where amopfamily=? and amoppurpose='o'
if r.amoplefttype is binary-coercible from the index column's type
then return true
As opposed to what I have now, which is:
get index column's opclass oid
look it up in pg_opclass to get opfamily/opcintype
result = SearchSysCacheExists4(AMPROCNUM, ...)
(in theory this could produce a false positive if there's a distance
function but no actual operators to reference it, but I think that's the
opclass author's issue)
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2016-08-12 19:59:49 | Re: No longer possible to query catalogs for index capabilities? |
Previous Message | Tom Lane | 2016-08-12 19:36:15 | Re: Is there a way around function search_path killing SQL function inlining? |