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 1hrN37-0006o5-Gw for pgsql-performance@arkaria.postgresql.org; Sat, 27 Jul 2019 13:47:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hrN36-0007lM-7B for pgsql-performance@arkaria.postgresql.org; Sat, 27 Jul 2019 13:47:48 +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 1hrN35-0007ix-OQ for pgsql-performance@lists.postgresql.org; Sat, 27 Jul 2019 13:47:47 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrN32-0002QC-4u for pgsql-performance@lists.postgresql.org; Sat, 27 Jul 2019 13:47:47 +0000 Received: by mail-wm1-x344.google.com with SMTP id v19so49858114wmj.5 for ; Sat, 27 Jul 2019 06:47:43 -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=US4p/zo+tinXyN/uJoluYyD9fGct3weE2FHoIk9K9lc=; b=y/1uPNKNN0ptYHf53OlcyPK0WqIEwkCVyYu09OlQhjvGhJJwuiwsc5brEx/QESLQre OascpQTYyUQqCrKI7mqrOiSnbuVAAbytudcotfzgVVADlCdFg8TMJlK8HarT2EusAIPV YYbKNYYXUQxWLWLQn2Xgz3DYi5W1AbK9jUL46YQays14y+xDVLJQu7AK/AEvo4QBaTu3 /RCpceJzvMSLAtzc2ctXs3o8YeY/4sV+qUZjcfy0UOaco4AMxrxT0xpD8S8nCaQQGMWs NDfAN1WTXqHs82Fb8kzp8zkaaynrm+U+vuTNUq3DnGrpoFvvt4q3CDpTFI3C7nmcKKr5 MEsg== 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=US4p/zo+tinXyN/uJoluYyD9fGct3weE2FHoIk9K9lc=; b=tb4dZ0MITUc0TVKjFdwNKCTlCAX2l1IMcUS3TAIn1LLm+qXos6dHpU/MJvffk4kSGQ ZBTPbv54+MeOVKGuuxJvQbOSvVkXWLL/CGbDHdR47ytl+Oex2s0CFu5htz4URq4KJKRI hRElpwRJTafJZiyjSy+3Gcua36glpAHCDfKD6AgR7Bl5deVpZ5jZ80N6osLsJjPg+EpU CUqXhewScFylorodaDdUK0rMwIgGLYOv2pyhFNNrMJTYk9oxXQs5HvCOGhlHpaCc7C7w ZuBiBZTKWs6CsjA3edReDs+iCUqb8eSOQmVwUtHa8KdzX7V/r6vWc2sJ0N69OSh4R5yk LxBA== X-Gm-Message-State: APjAAAX686qC56erpnpqm1xy3KfsKMP48lgwxhYJUJ4K7ixBERjeKrMG g2uzB7rcTCv6PkFME0uOsj+Z9Q== X-Google-Smtp-Source: APXvYqyrVAMCtn/m7Ak/k+MGdxPqzVuW9PVVMIpsKg3+l6Cela1mCn2gnySQosjOKJfsOgcDrUMgvw== X-Received: by 2002:a1c:c14b:: with SMTP id r72mr74758367wmf.166.1564235259634; Sat, 27 Jul 2019 06:47:39 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id x8sm46289850wmc.5.2019.07.27.06.47.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 27 Jul 2019 06:47:37 -0700 (PDT) Date: Sat, 27 Jul 2019 15:47:36 +0200 From: Tomas Vondra To: Ancoron Luciferis Cc: pgsql-performance@lists.postgresql.org Subject: Re: Standard uuid vs. custom data type uuid_v1 Message-ID: <20190727134736.xmzqbo2uoigmfkkv@development> References: <2d21f58d-230b-27b9-e48c-dda23a258066@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <2d21f58d-230b-27b9-e48c-dda23a258066@googlemail.com> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jul 25, 2019 at 11:26:23AM +0200, Ancoron Luciferis wrote: >Hi, > >I have finally found some time to implement a custom data type optimized >for version 1 UUID's (timestamp, clock sequence, node): >https://github.com/ancoron/pg-uuid-v1 > >Some tests (using a few millions of rows) have shown the following >results (when used as a primary key): > >COPY ... FROM: ~7.8x faster (from file - SSD) >COPY ... TO : ~1.5x faster (no where clause, sequential output) > >The best thing is that for INSERT's there is a very high chance of >hitting the B-Tree "fastpath" because of the timestamp being the most >significant part of the data type, which tends to be increasing. > >This also results in much lower "bloat", where the standard "uuid" type >easily goes beyond 30%, the "uuid_v1" should be between 10 and 20%. > >Additionally, it also reveals the massive performance degrade I saw in >my tests for standard UUID's: > >Initial 200 million rows: ~ 80k rows / second >Additional 17 million rows: ~26k rows / second > >...and the new data type: >Initial 200 million rows: ~ 623k rows / second >Additional 17 million rows: ~618k rows / second > Presumably, the new data type is sorted in a way that eliminates/reduces random I/O against the index. But maybe that's not the case - hard to say, because the linked results don't say how the data files were generated ... regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services