char(N), varchar(N), varchar, text

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: char(N), varchar(N), varchar, text
Date: 2014-10-08 14:22:44
Message-ID: 543548B4.4060700@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<small>Good morning, <br>
<br>
For performance point of view, are there big differences between:
char(N), varchar(N), varchar, text? <br>
</small>
<p><small>Some comments from google shows: <br>
No difference, under the hood it's all varlena. Check this
article from Depesz: <a
href="http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/">http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/</a><br>
A couple of highlights:</small></p>
<small>
</small>
<blockquote><small> </small>
<p><small>To sum it all up:</small></p>
<small> </small>
<ul>
<li><small>char(n) &#8211; takes too much space when dealing with
values shorter than n, and can lead to subtle errors because
of adding trailing spaces, plus it is problematic to change
the limit</small></li>
<li><small>varchar(n) &#8211; it's problematic to change the limit in
live environment</small></li>
<li><small>varchar &#8211; just like text</small></li>
<li><small>text &#8211; for me a winner &#8211; over (n) data types because
it lacks their problems, and over varchar &#8211; because it has
distinct name</small></li>
</ul>
<small>
So, can I assume no big performance differences? <br>
Thanks alot!<br>
Emi<br>
</small></blockquote>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.6 KB

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Andrew Dunstan 2014-10-08 14:30:11 Re: char(N), varchar(N), varchar, text
Previous Message Andrey Lizenko 2014-10-08 09:48:35 Re: query plan question, nested loop vs hash join