Skip site navigation (1) Skip section navigation (2)

Re: performance cost for varchar(20), varchar(255), and text

From: Shane Ambler <pgsql(at)Sheeky(dot)Biz>
To: Jessica Richard <rjessil(at)yahoo(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: performance cost for varchar(20), varchar(255), and text
Date: 2008-07-05 16:27:58
Message-ID: 486FA10E.3040004@Sheeky.Biz (view raw or flat)
Thread:
Lists: pgsql-admin
Jessica Richard wrote:
> I am tuning a database created by someone else.
> 
> I noticed that some column lengths were defined longer than needed.
> 
> For example, an Id column is holding a stand length of 20 characters
> but was defined as varchar(255).
> 
> On some other columns, for example, a Description column is supposed
> to hold less than 100 characters but defined as text.
> 
> I am trying to understand the performance impact if a column is over
> defined in the following cases:
> 
> 1. char(20) vs varchar(20)
> 
> 2. varchar(20) vs varchar(255)
> 
> 3. varchar(255) vs text
> 
> 
> thanks, Jessica
> 

 From the manual -
<quote>
Tip: There are no performance differences between these three types,
apart from increased storage size when using the blank-padded type, and
a few extra cycles to check the length when storing into a
length-constrained column. While character(n) has performance advantages
in some other database systems, it has no such advantages in PostgreSQL.
In most situations text or character varying should be used instead.
</quote>

http://www.postgresql.org/docs/8.3/static/datatype-character.html


-- 

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

In response to

pgsql-admin by date

Next:From: Mikko PartioDate: 2008-07-07 08:28:28
Subject: Re: Recommended RAID for Postgres
Previous:From: LewDate: 2008-07-05 15:04:53
Subject: Re: performance cost for varchar(20), varchar(255), and text

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group