Re: Domains vs data types

From: Ron Clarke <rclarkeai(at)gmail(dot)com>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Ertan Küçükoglu <ertan(dot)kucukoglu(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Domains vs data types
Date: 2025-08-20 16:56:47
Message-ID: CAGVf-sMLRbWsff5x3_s6vGisQCLy7LPTmJMOWoyaORy6yBC+Wg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Opinion: domains are useful if you give them names that are full of
meaning. For example if you have the same type of data accross tables
"item_number" or "account" etc so that you can use them to describe what
you want stored in them and ensure the same defaults, nulls etc are applied
accross tables. Having randomly named or encoded lists just makes life more
complicated.

On Wed, 20 Aug 2025, 18:13 Greg Sabino Mullane, <htamfids(at)gmail(dot)com> wrote:

> On Wed, Aug 20, 2025 at 12:48 AM Ertan Küçükoglu <
> ertan(dot)kucukoglu(at)gmail(dot)com> wrote:
>
>> 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?
>>
>
> Same disk space. No disadvantage other than confusing your users, and any
> performance differences will be so minor as to be unmeasurable. (my two
> cents: domains are best when the data type is complex AND shared across
> multiple tables. Even then I tend to avoid them.)
>
> Cheers,
> Greg
>
> --
> Crunchy Data - https://www.crunchydata.com
> Enterprise Postgres Software Products & Tech Support
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2025-08-20 17:01:30 Re: Domains vs data types
Previous Message Greg Sabino Mullane 2025-08-20 16:26:19 Re: vacuum analyze query performance - help me understand