pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Kevin Grittner <kgrittn@gmail.com>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers\@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: No longer possible to query catalogs for index capabilities?
Date: Fri, 12 Aug 2016 20:37:09 +0100
Message-ID: <874m6pol1i.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <9594.1471028028@sss.pgh.pa.us>
References: <20160809155623.GA567087@alvherre.pgsql>
	<87y445ap58.fsf@news-spur.riddles.org.uk>
	<87a8gkr8fu.fsf@news-spur.riddles.org.uk>
	<17563.1470843700@sss.pgh.pa.us>
	<8737mcr3vn.fsf@news-spur.riddles.org.uk>
	<30901.1470868017@sss.pgh.pa.us>
	<87fuq9oo12.fsf@news-spur.riddles.org.uk>
	<9594.1471028028@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.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)


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (69+ messages)  latest in thread

Message-ID: <874m6pol1i.fsf@news-spur.riddles.org.uk>
Permalink:  ../874m6pol1i.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/874m6pol1i.fsf@news-spur.riddles.org.uk

 · 

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-hackers@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, kgrittn@gmail.com, sfrost@snowman.net, peter.eisentraut@2ndquadrant.com, robertmhaas@gmail.com
  Subject: Re: No longer possible to query catalogs for index capabilities?
  In-Reply-To: <874m6pol1i.fsf@news-spur.riddles.org.uk>
  References: <20160809155623.GA567087@alvherre.pgsql> <87y445ap58.fsf@news-spur.riddles.org.uk> <87a8gkr8fu.fsf@news-spur.riddles.org.uk> <17563.1470843700@sss.pgh.pa.us> <8737mcr3vn.fsf@news-spur.riddles.org.uk> <30901.1470868017@sss.pgh.pa.us> <87fuq9oo12.fsf@news-spur.riddles.org.uk> <9594.1471028028@sss.pgh.pa.us> <874m6pol1i.fsf@news-spur.riddles.org.uk>

* 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