pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ancoron Luciferis <ancoron.luciferis@googlemail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Index with new opclass not used for sorting
Date: Fri, 21 Jun 2019 23:14:30 +0200
Message-ID: <8abfcad6-7f2a-8a3a-7efb-6610f6978b18@googlemail.com> (raw)
In-Reply-To: <28343.1561124192@sss.pgh.pa.us>
References: <271e728c-80dd-e3ee-508b-a21017d2e519@googlemail.com>
	<28343.1561124192@sss.pgh.pa.us>

On 21/06/2019 15:36, Tom Lane wrote:
> Ancoron Luciferis <ancoron.luciferis@googlemail.com> writes:
>> I am creating a new operator class for version 1 UUID's with an
>> extension and thought I was almost done by implementing everything
>> including SortSupport and creating a new opclass as follows:
> 
>> CREATE OPERATOR CLASS uuid_timestamp_ops FOR TYPE uuid
>>     USING btree AS
>>         OPERATOR        1       <*,
>> ...
> 
>> ...but when sorting on an (unique) index column, I still get a separate
>> sort, not using the index, e.g.:
> 
> You did not show your test query, but I imagine it just asked for the
> type's ordinary sort order, which is not what this opclass is claiming
> to provide.  To rely on the index's sort order you'd need something like
> 
> 	select id from uuid_v1_ext
> 	  where id <* '2b55fb04-33d8-11e9-9cfa-e03f494ffcf7'
> 	  order by id using <* ;
> 
> If you want this opclass to become the default sort order for uuid
> you'd have to remove the opcdefault marking from uuid_ops and attach
> it to this opclass instead.  No, I'm not sure that that wouldn't have
> unpleasant side-effects.
> 
> 			regards, tom lane
> 

OK, I somehow feared I'd be getting such an answer.

But thanks a lot for the "using <*" trick, which I somehow didn't know
even exists. That solves the problem for me at least.

Because of this issue I was already thinking about creating a new data
type which is basically just a new name for the existing "uuid" but
would enforce version 1, for which I then could provide the opclass as
default, or?

Btw. is there some example how to create derived types for PG properly
without copy/paste of a lot of existing code?

Thanx a lot and cheers,

	Ancoron





view thread (3+ messages)

Message-ID: <8abfcad6-7f2a-8a3a-7efb-6610f6978b18@googlemail.com>
Permalink:  ../8abfcad6-7f2a-8a3a-7efb-6610f6978b18@googlemail.com/
Also on:    postgresql.org/message-id/8abfcad6-7f2a-8a3a-7efb-6610f6978b18@googlemail.com

 · 

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-general@postgresql.org
  Cc: ancoron.luciferis@googlemail.com, tgl@sss.pgh.pa.us
  Subject: Re: Index with new opclass not used for sorting
  In-Reply-To: <8abfcad6-7f2a-8a3a-7efb-6610f6978b18@googlemail.com>
  References: <271e728c-80dd-e3ee-508b-a21017d2e519@googlemail.com> <28343.1561124192@sss.pgh.pa.us> <8abfcad6-7f2a-8a3a-7efb-6610f6978b18@googlemail.com>

* 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