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 1hUewE-0004DD-Sm for pgsql-performance@arkaria.postgresql.org; Sat, 25 May 2019 22:14:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hUewC-0006NA-W2 for pgsql-performance@arkaria.postgresql.org; Sat, 25 May 2019 22:14:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hUewC-0006Mz-G5 for pgsql-performance@lists.postgresql.org; Sat, 25 May 2019 22:14:48 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hUew4-0006qL-QO for pgsql-performance@lists.postgresql.org; Sat, 25 May 2019 22:14:46 +0000 Received: by mail-wm1-x342.google.com with SMTP id 7so12327339wmo.2 for ; Sat, 25 May 2019 15:14:40 -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=o2XI9XkNLWSUIPDlmns092u7a9ZbITEh5X+ffn/6PVI=; b=rDuMaBY/30VetsbNXRDnN1aB+jY8GE7PEPEdRFWSDud6mA55Kl0gLlsHlQ+teeA70M BMLps5ghqiLogKes3E3K0ksWIIw3+dwTXDf2BfmjnmVc6TndpoYrds2375Ube6yTTz+2 wngrd7qgrLCYEUyL3VxaTpRc/KFOvGVqEDkM2Vkl3Z3KOuIFYTK5auerPbZGqYAXXOku CD5sQH0i/g7yp+mWy6HPqDSpFKcF39sNOPK+mthJIYaUoXcXXnHh3f8+cMJXzQmGt+kc aCjeS07zuqYjCawZtChxvcYg0a+LY5Ybk1jdFxCOsS0xz/PUN0yXdEX5bb9o36nlA9aR IdIw== 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=o2XI9XkNLWSUIPDlmns092u7a9ZbITEh5X+ffn/6PVI=; b=jqlcyhHo40sTnhBO5ehafIBltJ76NNYj+2R9DEnDfAZ0onGBrRwGGh2faS7v4tGe0i GB7S4wwzopThdWAvMAmN3y9MMQU07HOIY5uPfutFCx3JVRSFJgRxpjac9ToNNNAAIp1u bhh7PFIi4nyQeVqhlRjq/d6EUoMeznzBwK33DACUofznBDFKjrYVTrXm+YtKHB71intM 8jsxXRARkGlCpJOJvr1e0vbGeNiOEQn9YwATrhOLrg9vadQb7rmVDBu3G1JHausXgIXB iEqvR2OTVH+RPVo/D0nhBJHVcwMCGub7C1Ix8ntrFmmsJdNCPEVp/MWEDHVt19zhlXla kj8w== X-Gm-Message-State: APjAAAWdHREU3z1Ap8ODurhza3ZuLGUaBFs/KTEowvGhfY4eMBSOCox6 2TGR7ijjhd6aCoDPJ+jwn/sR+A== X-Google-Smtp-Source: APXvYqz/HuR3l3DNwScs9fM8mTIHFqXy1h7AT3upupM4i6mvkMeqvF51cqsC7Z9C2FwcOtaXo2NQ+Q== X-Received: by 2002:a1c:cb05:: with SMTP id b5mr4700719wmg.146.1558822478272; Sat, 25 May 2019 15:14:38 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id 88sm18327450wrc.33.2019.05.25.15.14.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 25 May 2019 15:14:30 -0700 (PDT) Date: Sun, 26 May 2019 00:14:28 +0200 From: Tomas Vondra To: Tom Lane Cc: Ancoron Luciferis , pgsql-performance@lists.postgresql.org Subject: Re: UUID v1 optimizations... Message-ID: <20190525221428.3yc6hhvj7aawjpjv@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <14074.1558821255@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 05:54:15PM -0400, Tom Lane wrote: >Ancoron Luciferis writes: >> On 25/05/2019 16:57, Tom Lane wrote: >>> (4) it in fact *wouldn't* do anything useful, because we'd still have >>> to sort UUIDs in the same order as today, meaning that btree index behavior >>> would remain the same as before. Plus UUID comparison would get a lot >>> more complicated and slower than it is now. > >> I get your first sentence, but not your second. I know that when >> changing the internal byte order we'd have to completed re-compute >> everything on-disk (from table to index data), but why would the sorting >> in the index have to be the same? > >Because we aren't going to change the existing sort order of UUIDs. >We have no idea what applications might be dependent on that. > >As Vitalii correctly pointed out, your beef is not with the physical >storage of UUIDs anyway: you just wish they'd sort differently, since >that is what determines the behavior of a btree index. But we aren't >going to change the sort ordering because that's an even bigger >compatibility break than changing the physical storage; it'd affect >application-visible semantics. > >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. The thing is - it's not really desirable to get perfectly ordered ordering, because that would mean we never get back to older parts of the index (so if you delete data, we'd never fill that space). [1] https://www.2ndquadrant.com/en/blog/sequential-uuid-generators/ regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services