Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xbs8i-0000Mg-IW for pgsql-performance@arkaria.postgresql.org; Wed, 08 Oct 2014 14:22:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xbs8h-0002rg-9t for pgsql-performance@arkaria.postgresql.org; Wed, 08 Oct 2014 14:22:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xbs8g-0002rZ-4W for pgsql-performance@postgresql.org; Wed, 08 Oct 2014 14:22:50 +0000 Received: from oldperseverance.encs.concordia.ca ([132.205.96.92]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xbs8c-00058s-JH for pgsql-performance@postgresql.org; Wed, 08 Oct 2014 14:22:48 +0000 Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by oldperseverance.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id s98EMimD002610 for ; Wed, 8 Oct 2014 10:22:45 -0400 Message-ID: <543548B4.4060700@encs.concordia.ca> Date: Wed, 08 Oct 2014 10:22:44 -0400 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.1 MIME-Version: 1.0 To: "pgsql-performance@postgresql.org" Subject: char(N), varchar(N), varchar, text Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on oldperseverance.encs.concordia.ca at 2014-10-08 10:22:45 EDT X-Pg-Spam-Score: -1.2 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Good morning,

For performance point of view, are there big differences between: char(N), varchar(N), varchar, text?

Some comments from google shows:
No difference, under the hood it's all varlena. Check this article from Depesz: http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/
A couple of highlights:

To sum it all up:

  • char(n) – 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
  • varchar(n) – it's problematic to change the limit in live environment
  • varchar – just like text
  • text – for me a winner – over (n) data types because it lacks their problems, and over varchar – because it has distinct name
So, can I assume no big performance differences?
Thanks alot!
Emi