pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Gavan Schneider <list.pg.gavan@pendari.org>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Martin Mueller <martinmueller@northwestern.edu>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: A simple question about text fields
Date: Fri, 18 Jun 2021 08:49:01 +0200
Message-ID: <2a26524e395daee321efe6ffc391fd2debec55dc.camel@cybertec.at> (raw)
In-Reply-To: <2DE3A34D-EEC7-4167-B8FA-3BB168410B7B@pendari.org>
References: <A213AB92-F8BA-4585-98E5-D709FB3BD36B@northwestern.edu>
<677775.1623856129@sss.pgh.pa.us>
<E6ACFF8F-2953-4604-BC54-9AEA63A7F566@pendari.org>
<CAKFQuwZj=Vpoqeq0agPh0cct+qMijhGu1hv0hH05BZV-Kng1_A@mail.gmail.com>
<2DE3A34D-EEC7-4167-B8FA-3BB168410B7B@pendari.org>
On Fri, 2021-06-18 at 10:28 +1000, Gavan Schneider wrote:
> On 18 Jun 2021, at 9:34, David G. Johnston wrote:
> > On Thursday, June 17, 2021, Gavan Schneider <list.pg.gavan@pendari.org> wrote:
> >
> > > My approach is to define such fields as ‘text’ and set a constraint using
> > > char_length(). This allows PG to do the business with the text in native
> > > form, and only imposes the cost of any length check when the field is
> > > updated… best of both worlds.
> > >
> >
> > Those are basically the same world…your alternative probably is strictly
> > worse than varchar(n) because of its novel way of implementing the same
> > functionality.
>
> Not sure if this is strictly true. Novelty per se is not always worse. :)
True in general, but not in this case.
There is no advantage in a "text" with a check constraint on the length,
that is, no added functionality.
And it is worse for these reasons:
- the performance will be worse (big reason)
- the length limit is less obvious if you look at the table definition
(small reason)
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
view thread (6+ messages)
Message-ID: <2a26524e395daee321efe6ffc391fd2debec55dc.camel@cybertec.at> Permalink: ../2a26524e395daee321efe6ffc391fd2debec55dc.camel@cybertec.at/ Also on: postgresql.org/message-id/2a26524e395daee321efe6ffc391fd2debec55dc.camel@cybertec.at ·
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: laurenz.albe@cybertec.at, list.pg.gavan@pendari.org, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, martinmueller@northwestern.edu Subject: Re: A simple question about text fields In-Reply-To: <2a26524e395daee321efe6ffc391fd2debec55dc.camel@cybertec.at> References: <A213AB92-F8BA-4585-98E5-D709FB3BD36B@northwestern.edu> <677775.1623856129@sss.pgh.pa.us> <E6ACFF8F-2953-4604-BC54-9AEA63A7F566@pendari.org> <CAKFQuwZj=Vpoqeq0agPh0cct+qMijhGu1hv0hH05BZV-Kng1_A@mail.gmail.com> <2DE3A34D-EEC7-4167-B8FA-3BB168410B7B@pendari.org> <2a26524e395daee321efe6ffc391fd2debec55dc.camel@cybertec.at> * 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