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 1iNWSz-00021s-27 for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 06:19:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iNWSx-0007aj-Lx for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 06:19:23 +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 1iNWSx-0007ac-Ca for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 06:19:23 +0000 Received: from mout.kundenserver.de ([212.227.17.13]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNWSv-0004Od-6A for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 06:19:23 +0000 Received: from [10.8.0.75] ([185.40.248.10]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPSA (Nemesis) id 1Mj8eB-1hkuWn1Ggn-00fCFm for ; Thu, 24 Oct 2019 08:19:16 +0200 Subject: Re: Composite type storage overhead To: pgsql-general@lists.postgresql.org References: <90AA42A6-38FC-4117-90B5-4539302CA154@gmail.com> From: Thomas Kellerer Message-ID: <2d715b05-dce4-9aec-e01b-cb3213386f5c@gmx.net> Date: Thu, 24 Oct 2019 08:19:14 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:WeZd9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u4aOrpcOdKlbL Es08sspMhNhTMW6+yNO/96SJ9JsnHA0EpVdXiIhQiwKgTQ+Sz57JvMrBTXCuuYZKbT5LO1IeI Po5Qk1K1tIMA2At+v2kzQKU4BPtwnaLg9ZrYBVvEY= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > 3. The value is logically defined as a 128-bit integer, that is in > itself a compound value split into a few "bit groups". Extracting > these parts can be done by simple (and supposedly efficient) bitwise > operators when stored as integer, but becomes much more cumbersome > with UUID, I guess. This is usually a bad idea. Putting logic into the primary key value and merging different types of information in a single column is typically not such a good idea. (And it violates first normal form to begin with) I would strongly recommend to revisit this idea, and e.g. think about a multi-column primary key instead. Where each of these "groups" are stored in a separate column where the actual (business) value can be retrieved without any bitshifting or similar operations. Thomas