On 2011-08-03, Raj Mathur (=?utf-8?b?4KSw4KS+4KSc?= 
=?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=) <r...@linux-delhi.org> wrote:
> Hi,
>
> Can you point me to any pages that explain the difference between using, 
> say CHAR(8) vs VARCHAR(8) as the primary key for a table?  Is there any 
> impact on the database in terms of:

look in the data types chapter of the manual

> - Speed of indexed retrieval
> - Speed of join from a referencing table
> - Storage (I presume VARHAR(8) would have a slight edge, in general)
> - Any other issue

Unless you need the padding, and/or the length constraints use text.

("usr/share/doc/postgresql-doc-8.4/html/datatype-character.html")

.     Tip:  There is no performance difference among these three types,
. apart from increased storage space when using the blank-padded type,
. and a few extra CPU cycles to check the length when storing into a
. length-constrained column. While character(n) has performance
. advantages in some other database systems, there is no such advantage
. in PostgreSQL; in fact character(n) is usually the slowest of the
. three because of its additional storage costs. In most situations text
. or character varying should be used instead. 

-- 
⚂⚃ 100% natural


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to