Re: Newbee question "Types"

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: ken(at)perfect-image(dot)com
Subject: Re: Newbee question "Types"
Date: 2002-12-05 23:12:45
Message-ID: web-2023225@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

Ken,

1. Using column type "char" vs "varchar" vs "text"
I understand the documented differences, but Why wouldn't
someone just use varchar(x) instead of plain char(x)? It's
definitely more flexable. Or would using char(x) just help one
stay in sql conformity? How about performance differences?
Disk space differences? Would not varchar(45) vs char(45)
consume less space if used with less than 45 characters?

In postgresql, CHAR is supplied for 3 reasons:
1) For compatibility with other database systems that use CHAR.
2) For SQL99 Compliance
3) For compatibility with software that expects space-filled CHAR
fields.

For a Postgres-native application, there is no reason to ever use CHAR.
It does not perform any better, and can lead to significant annoyance.

-Josh Berkus

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2002-12-05 23:32:37 Re: the "/usr/local/pgsql/data" directory size
Previous Message David Blood 2002-12-05 23:11:35 Re: Size for vacuum_mem

Browse pgsql-novice by date

  From Date Subject
Next Message Mark Wilson 2002-12-06 00:20:29 Re: Infinite Loop
Previous Message Josh Berkus 2002-12-05 22:56:54 Re: Test to see if currval will fail?