public inbox for [email protected]
help / color / mirror / Atom feedRe: Domains vs data types
2+ messages / 2 participants
[nested] [flat]
* Re: Domains vs data types
@ 2025-08-20 15:05 Adrian Klaver <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Klaver @ 2025-08-20 15:05 UTC (permalink / raw)
To: Ertan Küçükoglu <[email protected]>; [email protected]
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
[email protected]
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Domains vs data types
@ 2025-08-20 15:43 Ron Johnson <[email protected]>
parent: Adrian Klaver <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Ron Johnson @ 2025-08-20 15:43 UTC (permalink / raw)
To: pgsql-generallists.postgresql.org <[email protected]>
On Wed, Aug 20, 2025 at 11:05 AM Adrian Klaver <[email protected]>
wrote:
[snip]
>
> Personally I don't see that integer --> aint really helps.
>
No one's going to create the domain "aint", but a DB designer in a rigorous
environment _will_ create multiple, meaningfully-named domains, all of
which happen to be INTEGER. Makes large-team developing easier.
The alternative is Really Really Long column names, and consistent use of
agreed-upon suffixes.
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-08-20 15:43 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-20 15:05 Re: Domains vs data types Adrian Klaver <[email protected]>
2025-08-20 15:43 ` Ron Johnson <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox