Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5Eqb-0007p1-5v for pgsql-general@arkaria.postgresql.org; Mon, 10 Aug 2020 20:56:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5Eqa-0002Yt-4x for pgsql-general@arkaria.postgresql.org; Mon, 10 Aug 2020 20:56:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5EqZ-0002Xo-Tc for pgsql-general@lists.postgresql.org; Mon, 10 Aug 2020 20:56:43 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k5EqY-0005Ub-0p for pgsql-general@lists.postgresql.org; Mon, 10 Aug 2020 20:56:43 +0000 Received: by mail-pj1-x102b.google.com with SMTP id d4so690166pjx.5 for ; Mon, 10 Aug 2020 13:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=r5Ug313ljOJz0Ett45067k4HNX+S0hbX1uGZSRDD8A4=; b=IjCj0x+vgDzRJuIYKAfMW23cvfP5l5hnRN03ZPLV8iudBeazyUYr9cf4soOQfeip3O DfOYLGNHR02FzMzNP8gRo4vfEBZxKODPt17TJ3t7WG3tyP9wVXmBpWsjGZ79HGlwz+Rx zMBT5T+Wp4qPvy9pya2A7v591O2wKyPqqSoBOTdn4LWv+3b1WgfGDvdjkcwiPTKsp8Sm 3Gqivpb3QkKXSv7ezcWw6XTY317yRMI6VGNwK/3vtSWAA888uinkg2F69LY746EEiyuI 2jjp/G2k13Dd7ShXTVbI4NbFkhxLwMD8vdvVikhOnLCP60sZleA1ESuTkUwIwZpDu5N/ gzfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=r5Ug313ljOJz0Ett45067k4HNX+S0hbX1uGZSRDD8A4=; b=p74FF51R3Rn2QOXPczG2vh75uXS3M8PLdDHL480u7kmetJU0h8bEqSN5VFdf9VaBOp RMBoTuKRPCib+00EfA6MBoqW42KY5wEe+iOxoxgJLBtlEqyAKzT4hCywgMiiLsSlYKsy HzUuzFoUIp9HPnD248r1dUgLLZOEQiFY6+8/slZ32ne4DAmGSlAO28xMGJRrJJ73L09h zmgT6ncvxdhqlpBhEfZuCXTLOHm2PXuySgKUGxvGFrnNjFaDzOnr88WxurSCPgeDyoEH 6HEhMwsMl4J+ysfhV1HjykdiOPWTCHN9rBgN9KMOSsCJMSnnMIwDAsElA5Ax5vFjDnea aCpw== X-Gm-Message-State: AOAM533nO4ZZjG51Bhpn+vAYzF3b3XNnA8RQxVlXhYeMVnb6/CivrH7J 7yZ6wJcziCWXxRpb/NnMd5G7rTKFnqs= X-Google-Smtp-Source: ABdhPJx8vvcw57ynhCuzizw4sl/qOwdfnv4QQpEMUcNtGWgBznqy9c7FT2lLKv0z2PrPbNXiuf0SmQ== X-Received: by 2002:a17:902:b7c2:: with SMTP id v2mr25560651plz.34.1597092998730; Mon, 10 Aug 2020 13:56:38 -0700 (PDT) Received: from ?IPv6:2601:681:5500:dde0:701b:3590:da03:1fe6? ([2601:681:5500:dde0:701b:3590:da03:1fe6]) by smtp.gmail.com with ESMTPSA id f3sm24525654pfj.206.2020.08.10.13.56.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Aug 2020 13:56:38 -0700 (PDT) Subject: Re: UUID or auto-increment To: pgsql-general@lists.postgresql.org References: <837516231.2607507.1597077490690@mail.yahoo.com> <2663a1f2-7377-58e7-ad7d-a867fe75cb15@gmail.com> <20200810165332.GV29590@tamriel.snowman.net> From: Rob Sargent Message-ID: Date: Mon, 10 Aug 2020 14:56:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200810165332.GV29590@tamriel.snowman.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/10/20 10:53 AM, Stephen Frost wrote: > Greeitngs, > > * Ron (ronljohnsonjr@gmail.com) wrote: >> On 8/10/20 11:38 AM, Ravi Krishna wrote: >>> Finally UUID results in write amplication in wal logs.  Keep that in mind >>> if your app does lot of writes. >> >> Because UUID is 32 bytes, while SERIAL is 4 bytes? > > and because it's random and so will touch a lot more pages when you're > using it... > > Avoid UUIDs if you can- map them to something more sensible internally > if you have to deal with them. > > Thanks, > > Stephen > I suspect the increased storage cost is more related to the size of the record than to the ratio of the data types. What says two consecutively saved records ought to be stored on the same page or will likely be sought with the same search criterion. Serial ids put a time order (loosely) on the data which may be completely artificial.