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 1uokNo-009TNp-4G for pgsql-general@arkaria.postgresql.org; Wed, 20 Aug 2025 15:05:49 +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 1uokNn-0098zv-Gv for pgsql-general@arkaria.postgresql.org; Wed, 20 Aug 2025 15:05:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uokNn-0098zj-4w for pgsql-general@lists.postgresql.org; Wed, 20 Aug 2025 15:05:47 +0000 Received: from fhigh-a8-smtp.messagingengine.com ([103.168.172.159]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uokNl-000rbq-0o for pgsql-general@lists.postgresql.org; Wed, 20 Aug 2025 15:05:46 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 4EC991400419; Wed, 20 Aug 2025 11:05:45 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 20 Aug 2025 11:05:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1755702345; x=1755788745; bh=gu/aKfkaBtv/hX4WDC1tT+3h1QVE/eYrVDnQD2DI6u4=; b= cz9YtkTbsXQMvXGnE6uAzucFlIu1+/0UDJ5PxoZSCb7QicKGTHWhPyxz3FV0BoIi ZHwf/2Ldfk/rAqlPkulttelMXuJNzrjvzz6KU/Cr0U89kCj8MinOn51uNt2YSerM 1GKX8/RnwCj3IrMWkB2PjWqKpOPNZWNytQgfA1dd/dzyaH5a/NqLp+Awvus7kYRv a1Eyw3dL3sheldtR8MOdznOD5pQKBcd3QmroKixv/Mkkc6Zi4lOU8c1+c+jfvuQZ RqP9u5LG6clACVVD1F7YKmVdY70KHonuCChrEKkHbmPYGFKRTPlOWKD/J6c7+2Dt UW9SVYBDoXLqpaX0TjWD4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1755702345; x=1755788745; bh=g u/aKfkaBtv/hX4WDC1tT+3h1QVE/eYrVDnQD2DI6u4=; b=eGJFI21BxVwd9pfYb O3dMpfH6pClJvEYW5zWqBtPqSxBTHPHz3IGiku5CXjJO0fe9rZg5eS8WUZWedWa+ QEKcdmMQG7rFDYMEn2noMRoR5PCRkCps0iAcxdkH+y/ZnbJ31IX8N+zaH4CwHE86 JaS67gn97IyxVBRHMtfVp6A3OiGw8C212YygFoVMjNeLvMRdIFStHC8L6RHHy2Hx KDCcqf41ACxg9bRSyU4g9G83NzfIpS0Xui4MCpgn7nTcSsL34PdnZLai1FA4XU2u 1I33V3wjx2qPXEyVWJH1fxw91PG66BWcXP3X6BHE9xnf/378FdOlsev9ENVLzI8V S7ogQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduheekieekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpeelgeevkeekkeeuiefgtdevieeluefhfedufeetkeejffek jeeujeehgeehgeektdenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepvghrthgrnhdrkhhutghukhhoghhluhesghhm rghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrd hpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Aug 2025 11:05:44 -0400 (EDT) Message-ID: <7cdd7a73-5a61-451b-9556-5cb523cfb239@aklaver.com> Date: Wed, 20 Aug 2025 08:05:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Domains vs data types To: =?UTF-8?B?RXJ0YW4gS8O8w6fDvGtvZ2x1?= , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/19/25 21:47, Ertan Küçükoglu wrote: > Hello, > > I am using PostgreSQL 17.6. > I would like to learn if there is any benefit of using domains over data > types for table column definitions in terms of performance gain/loss. > > For example I might have table defined as below > create table test ( >   a integer, >   b integer, >   c integer, >   d varchar(5) > ); > > I might also have ame table defined as below > > create domain aint integer; > create domain s5 varchar(5); > > create table test_domain ( >   a aint, >   b aint, >   c aint, >   d s5 > ); > > Does the second table have any technical advantage/disadvantage over > plain data type definition? > Less metadata in memory? High metadata in memory? Less/increased disk space? See: https://www.postgresql.org/docs/current/catalog-pg-type.html for what is stored in system catalog for a domain vs a base type. Personally I don't see that integer --> aint really helps. Also I am pretty sure varchar(5) --> s5 is still going to result in a length check. > > Thanks & Regards, > Ertan -- Adrian Klaver adrian.klaver@aklaver.com