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 1tWB4q-00EktO-Vd for pgsql-general@arkaria.postgresql.org; Fri, 10 Jan 2025 09:13:14 +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 1tWB4o-00DpII-UK for pgsql-general@arkaria.postgresql.org; Fri, 10 Jan 2025 09:13:10 +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 1tWB4o-00DpIA-E0 for pgsql-general@lists.postgresql.org; Fri, 10 Jan 2025 09:13:10 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tWB4k-000sf1-0h for pgsql-general@lists.postgresql.org; Fri, 10 Jan 2025 09:13:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1736500385; bh=nelYfZQHQLjRwTE1iDf8YdUx6D79eeOSwYP0e/XUw6k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID:From; b=ZzTc2kyct5rLNPcfLgQn4XJZ4gLDnwFk0zP1yjD2Ld5P/SzVwjjn/OCLXzEr9Wl4g liAQ5BEra19vw5VbAz9G2IPbm6qEI2Siine83GKScGn3ZQvLh9RSKS8VLeUMddUkd/ /GxY42i2cDtFf2jRROYn+qZTYloEzL4okXSaMitTYUf1Td+zitZ00cS8qLgth7dGo/ VqupPX12pr5MVVwxbtpj+9w9CcVkQt6yMassARjK1GKft4TWuBgtIB6EbV0Ql0LC21 n03K3i+me234WOeCNz+I+T2j7H8Fmq+KuzMlmiR8lO84smQLBr1BNKp0SahJBVfY8C bGTTqtlsOUoxw== Received: from mail.postgrespro.ru (webmail-slave-mstn.l.postgrespro.ru [192.168.2.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: v.popolitov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 5F9A0607E8; Fri, 10 Jan 2025 12:13:05 +0300 (MSK) MIME-Version: 1.0 Date: Fri, 10 Jan 2025 16:13:05 +0700 From: Vladlen Popolitov To: Igor Korot Cc: Christophe Pettus , "David G. Johnston" , Ron Johnson , "pgsql-generallists.postgresql.org" Subject: Re: Postgres do not support tinyint? In-Reply-To: References: <11AA76D0-CAFE-4A17-BCCF-50520CCDF47F@thebuild.com> <051EB6AC-2395-4EAD-B30C-069FBC01107F@thebuild.com> Message-ID: <59d067bdcf17bd5a624eb7c736779853@postgrespro.ru> X-Sender: v.popolitov@postgrespro.ru Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected, bases: 2025/01/10 07:13:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/01/10 06:21:00 #26967412 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Igor Korot писал(а) 2025-01-09 02:40: > Hi, Christopphe, > > On Wed, Jan 8, 2025 at 1:34 PM Christophe Pettus > wrote: >> >> >> >> > On Jan 8, 2025, at 11:30, Igor Korot wrote: >> > There is no boolean - it is 0-4 inclusive. >> >> Unless you have somehow gotten PostgreSQL running on an IBM 7070, the >> range 0-4 can be represented by three binary digits, aka booleans. :-) > > The only booleans I know of are 0 and 1. ;-) > >> >> To be serious, though, the situation is: >> >> 1. If there are just one or two tinyints, having a tinyint type >> wouldn't save any space in the row. > > No it is not a lot of them. > So then "smallint" is the best bet, right? > > Thank you > >> 2. If there are a lot of them, it's worth encoding them into a >> bitstring. Hi! If you really need 1-byte integer, you can use "char" type. Cast it to/from int. See comment at the end of the page https://www.postgresql.org/docs/17/datatype-character.html -- Best regards, Vladlen Popolitov.