Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a4w9V-0007xh-Ra for pgsql-performance@arkaria.postgresql.org; Fri, 04 Dec 2015 19:36:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a4w9U-0007oP-OP for pgsql-performance@arkaria.postgresql.org; Fri, 04 Dec 2015 19:36:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a4w7r-0005un-5Y for pgsql-performance@postgresql.org; Fri, 04 Dec 2015 19:34:39 +0000 Received: from mail-ig0-x233.google.com ([2607:f8b0:4001:c05::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a4w7j-0004E9-Pz for pgsql-performance@postgresql.org; Fri, 04 Dec 2015 19:34:37 +0000 Received: by igl9 with SMTP id 9so39777826igl.0 for ; Fri, 04 Dec 2015 11:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uchicago-edu.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=Ig95FF7tWbayE0aupfxbpgg/cc7qPhayC9qe8o5n2CY=; b=gcieSoZOa6CjIZXbpcMDZfUjVQ+TEWQ+O9fyH1TVj0fazUnCDW3RZqklkRm4JtqrZE l4CiseSdryjzE7x4fXVp+2rO82tXb0ieWQ6U8zBr5jx5fSuZj6vvPGV1O97dI/BsfJTn 0Co2oKyy3oSTfyzOWlFboKKIa9nOYd9LpNrH0nxfMwVfxCEmeuQiobJnG1XuEaK5w5jl h15J1GfUpOuI8s5EyWBviXcOw24x5By2LRbmW3ZtIgjRF7cLwVFeEj4c41UXwHNvHTWr ix4V6IC6ZDwEgwT7i/dEzKS+AKqoJE24UJXFQim9ZHQssNBzBziuX/l22RwjqcsVsszb HcPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-type:content-transfer-encoding; bh=Ig95FF7tWbayE0aupfxbpgg/cc7qPhayC9qe8o5n2CY=; b=mrTxm6S0pEPfSx/RSkWpI+o22yzFLugzkSIfIrHRAzouRaEBtDMB1L3loEcwRiJ0d9 EA6udEXjtYC/bDXfP1MpaJMCh1/JyXfEWVoiN/p7fIUWdbF2wVcfLcKY+VuopVEK3W2z uxb4mQXL9tXfMxG/ymtQDvP1TTYd9adky214Zs45/7fEJ/jkN0QlJAO8uUgWDlGSMfjz wscli+/N/14Cwa82Xwb9Le9VyRC8Tlmm744j15R/5m6ODp2eX2p/gOMPTExFG3C2cBqA NpJJ6K1eZr8rgdOx+F0b/hoAf0wnssgWf0ezS9Fh9MWPGTggW5Pp2NiazMe11uezonnm qOiA== X-Gm-Message-State: ALoCoQkJ6g7/JdvpjDJpA9jekKmplZOkGvu6h8RZvjSVrpihVJbLmrWtCW//ACEESh4P0fVBXdNS X-Received: by 10.50.129.98 with SMTP id nv2mr5245549igb.97.1449257670730; Fri, 04 Dec 2015 11:34:30 -0800 (PST) Received: from [128.135.179.93] ([128.135.179.93]) by smtp.gmail.com with ESMTPSA id o10sm1882403igy.8.2015.12.04.11.34.29 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Dec 2015 11:34:30 -0800 (PST) To: pgsql-performance@postgresql.org From: Brendan McCollam Subject: ossp-uuid: Performance considerations for different UUID approaches? Message-ID: <5661EAC5.3030401@uchicago.edu> Date: Fri, 4 Dec 2015 13:34:29 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hello, We're in the process of designing the database for a new service, and some of our tables are going to be using UUID primary key columns. We're trying to decide between: * UUIDv1 (timestamp/MAC uuid) and * UUIDv4 (random uuid) And the separate but related choice between * Generating the UUIDs client-side with the Python uuid library (https://docs.python.org/2/library/uuid.html) or * Letting PostgreSQL handle uuid creation with the uuid-ossp extension (http://www.postgresql.org/docs/9.4/static/uuid-ossp.html) In terms of insert and indexing/retrieval performance, is there one clearly superior approach? If not, could somebody speak to the performance tradeoffs of different approaches? There seem to be sources online (e.g. https://blog.starkandwayne.com/2015/05/23/uuid-primary-keys-in-postgresql/ http://rob.conery.io/2014/05/29/a-better-id-generator-for-postgresql/) that claim that UUIDv4 (random) will lead to damaging keyspace fragmentation and using UUIDv1 will avoid this. Is that true? If so, does that mean UUIDv1 must always be generated on the same machine (with same MAC address) in order to benefit from the better clustering of UUIDs? What about uuid_generate_v1mc() in uuid-ossp? Not exposing a server's real MAC address seems like a good security feature, but does it compromise the clustering properties of UUIDv1? Thanks in advance, Brendan McCollam -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance