Re: A simple question about text fields

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martin Mueller <martinmueller(at)northwestern(dot)edu>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: A simple question about text fields
Date: 2021-06-16 15:08:49
Message-ID: 677775.1623856129@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martin Mueller <martinmueller(at)northwestern(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexey Bashtanov 2021-06-16 15:27:35 Streaming replication: PANIC on tertiary when secondary promoted
Previous Message Martin Mueller 2021-06-16 15:02:25 A simple question about text fields