pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Tim Kane <tim.kane@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: Alter domain type / avoiding table rewrite
Date: Tue, 16 Apr 2019 10:42:28 -0400
Message-ID: <27283.1555425748@sss.pgh.pa.us> (raw)
In-Reply-To: <9dc52f4b-94b5-813c-52ba-be22dec1cb93@aklaver.com>
References: <CADVWZZKjhV9fLpewPdQMZx7V6kvGJViwMEDrPAv9m50rGeK9UA@mail.gmail.com>
	<26216.1555423922@sss.pgh.pa.us>
	<9dc52f4b-94b5-813c-52ba-be22dec1cb93@aklaver.com>

Adrian Klaver <adrian.klaver@aklaver.com> writes:
> I suspect the OP wants the type to text with a CHECK constraint to allow 
> for increasing the length of field values in the future by just changing 
> the CHECK setting. If that is the case would changing the type to text 
> and then adding a CHECK NOT VALID work without too much pain?

I don't think we really support NOT VALID on domain constraints do we?

In any case, the point remains that domains are pretty inefficient
compared to native types like varchar(12); partly because the system
can't reason very well about arbitrary check constraints as compared
to simple length constraints, and partly because the whole feature
just isn't implemented very completely or efficiently.  So you'll be
paying *a lot* for some hypothetical future savings.

(Having said that, you're already paying a fair chunk of that
overhead with your existing domain type, so maybe it's not bothering
you.  But I'm worried that going from domain-without-check-constraint
to domain-with-check-constraint is going to bite you.)

			regards, tom lane





view thread (16+ messages)  latest in thread

Message-ID: <27283.1555425748@sss.pgh.pa.us>
Permalink:  ../27283.1555425748@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27283.1555425748@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, tim.kane@gmail.com
  Subject: Re: Alter domain type / avoiding table rewrite
  In-Reply-To: <27283.1555425748@sss.pgh.pa.us>
  References: <CADVWZZKjhV9fLpewPdQMZx7V6kvGJViwMEDrPAv9m50rGeK9UA@mail.gmail.com> <26216.1555423922@sss.pgh.pa.us> <9dc52f4b-94b5-813c-52ba-be22dec1cb93@aklaver.com> <27283.1555425748@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox