From: Tom Lane <tgl@sss.pgh.pa.us>
To: Martin Mueller <martinmueller@northwestern.edu>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: A simple question about text fields
Date: Wed, 16 Jun 2021 11:08:49 -0400
Message-ID: <677775.1623856129@sss.pgh.pa.us> (raw)
In-Reply-To: <A213AB92-F8BA-4585-98E5-D709FB3BD36B@northwestern.edu>
References: <A213AB92-F8BA-4585-98E5-D709FB3BD36B@northwestern.edu>
Martin Mueller <martinmueller@northwestern.edu> writes:
> Are there performance issues with the choice of 'text' vs. varchar and some character limit? For instance, if I have a table with ten million records and text fields that may range in length from 15 to 150, can I expect a measurable improvement in response time for using varchar(150) or will text do just or nearly as well.
There is no situation where varchar outperforms text in Postgres.
If you need to apply a length constraint for application semantic
reasons, do so ... otherwise, text is the native type. It's
useful to think of varchar as being a domain over text, though
for various reasons it's not implemented quite that way.
regards, tom lane
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, martinmueller@northwestern.edu
Subject: Re: A simple question about text fields
In-Reply-To: <677775.1623856129@sss.pgh.pa.us>
References: <A213AB92-F8BA-4585-98E5-D709FB3BD36B@northwestern.edu> <677775.1623856129@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