Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVPwj-008BHw-6C for pgsql-general@arkaria.postgresql.org; Wed, 08 Jan 2025 06:53:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tVPwi-00Dvmo-It for pgsql-general@arkaria.postgresql.org; Wed, 08 Jan 2025 06:53:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVPwi-00Dvks-7s for pgsql-general@lists.postgresql.org; Wed, 08 Jan 2025 06:53:39 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tVPwe-000U81-2Z for pgsql-general@lists.postgresql.org; Wed, 08 Jan 2025 06:53:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5086rYJt1590897; Wed, 8 Jan 2025 01:53:34 -0500 From: Tom Lane To: "David G. Johnston" cc: Ron Johnson , "pgsql-generallists.postgresql.org" Subject: Re: Postgres do not support tinyint? In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Tue, 07 Jan 2025 23:44:21 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1590895.1736319214.1@sss.pgh.pa.us> Date: Wed, 08 Jan 2025 01:53:34 -0500 Message-ID: <1590896.1736319214@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Tuesday, January 7, 2025, Ron Johnson wrote: >> 3. The "bit" type might serve your needs. > You suggest a type with a minimum size of 6 bytes when the complaint is > that the otherwise acceptable 2 byte data type is too large? I think the point here is that there's zero value in trying to pack a small integer value into 1 byte (let alone 4 bits) if it's all by its lonesome in the row. Alignment padding will eat whatever gain you thought you had. If you want a win, you need to store a lot of such values in one field. Ron's suggesting that you pack them into bit arrays and manually insert/extract individual values. That could be worth doing if you were sufficiently desperate, but you'd have to value compact storage over access simplicity quite a lot. Perhaps a "char"[] array (note the quotes) would provide an intermediate level of compactness versus pain. regards, tom lane