Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heJiY-0000rB-LZ for pgsql-general@arkaria.postgresql.org; Fri, 21 Jun 2019 13:36:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1heJiX-0000HM-DP for pgsql-general@arkaria.postgresql.org; Fri, 21 Jun 2019 13:36:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heJiX-0000HE-3s for pgsql-general@lists.postgresql.org; Fri, 21 Jun 2019 13:36:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heJiU-0000aH-UE for pgsql-general@lists.postgresql.org; Fri, 21 Jun 2019 13:36:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5LDaWq0028344; Fri, 21 Jun 2019 09:36:32 -0400 From: Tom Lane To: Ancoron Luciferis cc: pgsql-general@lists.postgresql.org Subject: Re: Index with new opclass not used for sorting In-reply-to: <271e728c-80dd-e3ee-508b-a21017d2e519@googlemail.com> References: <271e728c-80dd-e3ee-508b-a21017d2e519@googlemail.com> Comments: In-reply-to Ancoron Luciferis message dated "Fri, 21 Jun 2019 07:40:17 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28342.1561124192.1@sss.pgh.pa.us> Date: Fri, 21 Jun 2019 09:36:32 -0400 Message-ID: <28343.1561124192@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ancoron Luciferis 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