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 1kTSIa-0001E5-D0 for pgsql-general@arkaria.postgresql.org; Fri, 16 Oct 2020 16:09:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kTSIZ-0006Ph-4l for pgsql-general@arkaria.postgresql.org; Fri, 16 Oct 2020 16:09:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTSIY-0006Pa-TU for pgsql-general@lists.postgresql.org; Fri, 16 Oct 2020 16:09:42 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTSIS-00057h-Lc for pgsql-general@lists.postgresql.org; Fri, 16 Oct 2020 16:09:41 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 9E6665C00AD; Fri, 16 Oct 2020 12:09:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 16 Oct 2020 12:09:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=YilM1BjOKrxZCuAKq M/A17EiTjdgImihafhgMD7C1Bo=; b=Gcjrx0D2tbe8yOYMq1+At48kRPhk8vXdT ptEzfRNbVjo7Rvy4FvA7hvDLsUkH5x+H8rS+7Xe0FAcPkceBSxxqEHxIX4ChLg7o 9jTbaotu+vo8MkT2L8W758WLJj1gAaLdiTlAC5busU3FJEhWCsfvvMofrD0QeNMs Lwb/eF6MeTpM8f60BEp3QCVOSPlFbNPORzetLHHiq//S3ayBdJFUAFBwmH3UOjv1 V2FfyLBq4f0WxZIGjzm43Q0AgMqOqlppGTUpN4Yopx2mWy8p6FWeh0be/NnyL7DW S/OMPkggtfmxMFtOyK6IucjKjKMUSUHdzJ+DdecHMQrJxF/LbAMKA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrieehgdelkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrddutdeirddufeegrddutddtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (h100-n190-106-134.v8.fangio.net [190.106.134.100]) by mail.messagingengine.com (Postfix) with ESMTPA id E35B73064683; Fri, 16 Oct 2020 12:09:34 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 850172A14D3; Fri, 16 Oct 2020 13:09:32 -0300 (-03) Date: Fri, 16 Oct 2020 13:09:32 -0300 From: Alvaro Herrera To: Dirk Krautschick Cc: "pgsql-general@lists.postgresql.org" Subject: Re: UUID with variable length Message-ID: <20201016160932.GA32253@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Oct-15, Dirk Krautschick wrote: > Hi, > > I have here a situation with the usage of UUID. Here the database user > allows UUIDs with less then 16 byte lengths (please don't ask :-) ). > > Of course there are some technical ways to do the filling of the not > used bytes but I hope there is a better solution. This UUID is used as > primary Key and for indexing. How much shorter than 16 bytes are you expecting your UUIDs to be? If they're not short enough, you'll still have to store a lot of padding space, and considering that you'll need a length indicator if you use variable length, it does not really sound like you'll save much actual space. And you'll definitely be getting a slower datatype, since doing operations will become more complex. If this were me, I would see about zeroing out the unused bytes and not waste a lot of developer time on this.