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 1hUqWp-0001Cu-O0 for pgsql-performance@arkaria.postgresql.org; Sun, 26 May 2019 10:37:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hUqWo-0003oS-7J for pgsql-performance@arkaria.postgresql.org; Sun, 26 May 2019 10:37:22 +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 1hUqWn-0003oL-M9 for pgsql-performance@lists.postgresql.org; Sun, 26 May 2019 10:37:21 +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 1hUqWj-0006cu-F9 for pgsql-performance@lists.postgresql.org; Sun, 26 May 2019 10:37:20 +0000 Received: by mail-wm1-x342.google.com with SMTP id v19so4281261wmh.0 for ; Sun, 26 May 2019 03:37:17 -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=fjwjU32U6j+daLt8IBk9MgA2P0R6y/kpYez40AGOR7M=; b=LZC9thcnT7OpW1+HY16gUFCwmaytBehn05xwqwKFh5SmKIycMEcfsia01PNbKLsZ9+ v67ZYPo7Jctoja277iHK186jPKhhq93pNY4xb6JtZJUERCPL6HgM9bfKYRC5/+X8T5ve 04pvK72AJGEDtb7RQTZjOeJu/pCkEvByWh/ld0m7C5ucq3O/HgtaLTaOHzD2deooVM/z SdVqeLr7Pn9cVEEuzJquhRIyAZevp7f/2KvkPmnkjkSdv1Y35+e1+rqJ4OA1uFBDyqRg UmXmDtm4WKhGr3NggAYrzP7xlJFTOpMpG43vtMUDacEwhmEk4IlrKNJPjfOXSwRaOcVy ekIw== 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=fjwjU32U6j+daLt8IBk9MgA2P0R6y/kpYez40AGOR7M=; b=TQOx658w4GUwPRqaqsVMJSSbhZp99x868TiEy1m5eN46kXxsONzuEppeAettRHx+/Y 6XzdXH1ELmCUN+1WxpXFkvV/Gv//H9FzqtXvUvdPmvsB+jJK33WSj0wFz/JOkVf+GRAW unmRAJYitkkybnqrSMFSCYdeeyxnF9apMj/Tbi+0Vls01eUdgPIOsPqRE4Hfc44sfVI3 mfE1JJZcuDYCTLuY5+MtMhg2uoU1fA0pccbWcfpGrjSBaQL5E6C+W7cLF219EEgBGcuV ox+5YLsjITLw29dt+sm7O603nF7uKIb4ezU663gVY7y510lHmNUzBjvvvYqkRj+rO+8g uzDA== X-Gm-Message-State: APjAAAU34WhV7jWtLs9CkJevpp4eQcnO9lk0bZlFDGrH4zEqJnmG/fhG xxkZdRE75jJpJ4OK7n9/fMuwkQ== X-Google-Smtp-Source: APXvYqzaea2dsDJJCFLUAJgQhCz3t3kGoPO9rGJneWQR6MieBy0QhJgjAj5pMiM2vydXGWa3Lwr7sw== X-Received: by 2002:a1c:f61a:: with SMTP id w26mr22458191wmc.47.1558867035812; Sun, 26 May 2019 03:37:15 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id t15sm6287037wmt.2.2019.05.26.03.37.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 26 May 2019 03:37:08 -0700 (PDT) Date: Sun, 26 May 2019 12:37:07 +0200 From: Tomas Vondra To: Morris de Oryx Cc: pgsql-performance@lists.postgresql.org Subject: Re: UUID v1 optimizations... Message-ID: <20190526103707.4una3n34ycqdgmiy@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> <20190526010918.lrww6cw76halyu4w@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, May 26, 2019 at 02:27:05PM +1000, Morris de Oryx wrote: >I'm not worthy to post here, but a bit of a random thought. > >If I've followed the conversation correctly, the reason for a V1 UUID is >partly to order and partition rows by a timestamp value, but without the >cost of a timestamp column. As I was told as a boy, "Smart numbers aren't." >Is it _absolutely_ the case that you can't afford another column? I don't >know the ins and outs of the Postgres row format, but my impression is that >it's a fixed size, so you may be able to add the column without splitting >rows? Anyway, even if that's not true and the extra column costs you disk >space, is it the index that concerns you? Have you considered a timestamp >column, or a numeric column with an epoch offset, and a BRIN index? If you >insert data is in pretty much chronological order, that might work well for >you. > >Best of luck, I've enjoyed following the commentary. > No, an extra column is not a solution, because it has no impact on the index on the UUID column. One of the problems with indexes on random data is that the entries go to random parts of the index. In the extreme case, each index insert goes to a different index page (since the last checkpoint) and therefore has to write the whole page into the WAL. That's what full-page writes do. This inflates the amount of WAL, may trigger more frequent checkpoints and (of course) reduces the cache hit ratio for index pages (because we have to touch many of them). The point of generating UUIDs in a more sequential way is to limit this behavior by "concentrating" the index inserts into a smaller part of the index. That's why indexes on sequential data (say, generated from a SERIAL column) perform better. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services