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 1hUgL5-0007o8-Pa for pgsql-performance@arkaria.postgresql.org; Sat, 25 May 2019 23:44:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hUgL3-0000BF-WA for pgsql-performance@arkaria.postgresql.org; Sat, 25 May 2019 23:44:33 +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 1hUgL3-00009X-Iy for pgsql-performance@lists.postgresql.org; Sat, 25 May 2019 23:44:33 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hUgL0-0000Hh-0J for pgsql-performance@lists.postgresql.org; Sat, 25 May 2019 23:44:32 +0000 Received: by mail-wr1-x444.google.com with SMTP id r7so13303917wrr.13 for ; Sat, 25 May 2019 16:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=P3UvMuGiEmTilGD3l8wTt727iTO1F3kAaHMYWrcbs/k=; b=vYKBlyORDb/0T3O/TIuWiqIXH/KT1pJu3TYhGKeaFPt9zWE6Rj258KPfduMUVkZl27 YFyCzb7o8pUxQmfzR3A78Dt1DT4vdWDDt6nM7eUYrldUacPiWuqEHMXzltO45WOuwekj ESolCpN5oLUQuS5T8E4zJkDseU3FtOZxBDiQ2Ilg5l3jV9WAtki4ycu1eXN4ZpulFevM KGUTUJ8MNPC+8AudpY35Oes6I+VL1uO5+AowL8FiNYY3pEfBn7vFnBE6k0oR7X8KadCk P26EtfbhxI1AS7eiEAF37ipkKI7owY2FBd8fJoDG8O9ruYwLy8sZ7dQSonyliRD50B1e fwRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=P3UvMuGiEmTilGD3l8wTt727iTO1F3kAaHMYWrcbs/k=; b=LATSfu0ychwADwNeTi1bRYkz9nUL++g/1k4aYF4JENnFlbusBuvAvivq/hbunvE/T5 waZA0bbkn0hHvo5X5vGvwJGZyOypBWai1ke2ng9k1vaQ+QNVqgkEIRdYsBwRBPkLFYQ/ GWCcwpVYp1TEWLG0uGN5ZJbUFJlfhxdOU5PPGy7OBM9YOpojorNjWmoG2YrcXYozknB8 ccDOJNAnLacK6PFey4benpOssi8uJDoecWEuVkQAT65lSPFDQPOHgn6nbTcG/u40S1k5 lVvxkqv8hcIHJEgx+8G/nR38uRIU4iTroIo1M9ZTecfY1vGZIqIwTlYKlhLL4R4FjYXZ MeRw== X-Gm-Message-State: APjAAAVR+K5L9XgUmC9mNOrRkKL0Vt+pPdwMiWLdjAu3CRrI/C/lvQVG lVL+yJM8p8P+nTaVI9kES1trqg== X-Google-Smtp-Source: APXvYqyYgthCSeQWrQ1Gn8toUUFCUVkgr30cwtSEI9JyLD9qPhSlnrFhmoXZPQWH71vCC4MBH/P1iQ== X-Received: by 2002:adf:e58a:: with SMTP id l10mr14913086wrm.163.1558827867096; Sat, 25 May 2019 16:44:27 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id q16sm4808140wmj.17.2019.05.25.16.44.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 25 May 2019 16:44:20 -0700 (PDT) Date: Sun, 26 May 2019 01:44:18 +0200 From: Tomas Vondra To: Tom Lane Cc: Ancoron Luciferis , pgsql-performance@lists.postgresql.org Subject: Re: UUID v1 optimizations... Message-ID: <20190525234418.q3dcnirxog3dptwd@development> References: <8d5f4b67-d540-8d3d-9979-808b9c1e1ca7@googlemail.com> <20635.1558796270@sss.pgh.pa.us> <19faa3aa-a103-b991-ff20-b73852085f30@googlemail.com> <14074.1558821255@sss.pgh.pa.us> <20190525221428.3yc6hhvj7aawjpjv@development> <21750.1558823888@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <21750.1558823888@sss.pgh.pa.us> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, May 25, 2019 at 06:38:08PM -0400, Tom Lane wrote: >Tomas Vondra writes: >> On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote: >>> What you might want to think about is creating a function that maps >>> UUIDs into an ordering that makes sense to you, and then creating >>> a unique index over that function instead of the raw UUIDs. That >>> would give the results you want without having to negotiate with the >>> rest of the world about whether it's okay to change the semantics >>> of type uuid. > >> FWIW that's essentially what I implemented as an extension some time >> ago. See [1] for a more detailed explanation and some benchmarks. > >Also, another way to attack this is to create a new set of ordering >operators for UUID and an associated non-default btree opclass. >Then you declare your index using that opclass and you're done. >The key advantage of this way is that the regular UUID equality >operator can still be a member of that opclass, meaning that searches >of the form "uuidcol = constant" can still use this index, so you >don't have to change your queries (at least not for that common case). >Look at the interrelationship of the regular text btree operators and >the "pattern_ops" btree operators for a precedent. > Perhaps. But it does not allow to tune how often the values "wrap" and, which I think is an useful capability. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services