text .vs. varchar

Started by Joao Ferreiraover 17 years ago4 messagesgeneral
Jump to latest
#1Joao Ferreira
jmcferreira@critical-links.com

Hello all,

I have a big database in which much information is stored in TEXT type
columns (I did this initially because I did not want to limit the
maximum size of the string to be stored)... but...

.. let's say I choose an upper limit (p.ex. 200) for the string sizes
and I start a fresh database with VARCHAR(200).

What tradeoffs can I expect ? disk usage ? query execution times ?

thx
Joao

#2Bill Moran
wmoran@collaborativefusion.com
In reply to: Joao Ferreira (#1)
Re: text .vs. varchar

In response to Joao Ferreira <jmcferreira@critical-links.com>:

Hello all,

I have a big database in which much information is stored in TEXT type
columns (I did this initially because I did not want to limit the
maximum size of the string to be stored)... but...

.. let's say I choose an upper limit (p.ex. 200) for the string sizes
and I start a fresh database with VARCHAR(200).

What tradeoffs can I expect ? disk usage ? query execution times ?

See the "Tip" on this page, it answers your questions:
http://www.postgresql.org/docs/8.3/static/datatype-character.html

--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023

#3Martin Gainty
mgainty@hotmail.com
In reply to: Bill Moran (#2)
Re: text .vs. varchar

With Postgres appears that TEXT is preferred over varchar(N)
http://archives.postgresql.org/pgsql-general/2006-03/msg01522.php

Any other DB (e.g. Oracle) would suggest varchar as column only stores the length of the variable (variable character length..) vs any of the fixed length datatype(s)

Anyone else?
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.

Date: Wed, 13 Aug 2008 08:45:19 -0400
From: wmoran@collaborativefusion.com
To: jmcferreira@critical-links.com
CC: pgsql-general@postgresql.org
Subject: Re: [GENERAL] text .vs. varchar

In response to Joao Ferreira <jmcferreira@critical-links.com>:

Hello all,

I have a big database in which much information is stored in TEXT type
columns (I did this initially because I did not want to limit the
maximum size of the string to be stored)... but...

.. let's say I choose an upper limit (p.ex. 200) for the string sizes
and I start a fresh database with VARCHAR(200).

What tradeoffs can I expect ? disk usage ? query execution times ?

See the "Tip" on this page, it answers your questions:
http://www.postgresql.org/docs/8.3/static/datatype-character.html

--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023

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

_________________________________________________________________
Get more from your digital life. Find out how.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Martin Gainty (#3)
Re: text .vs. varchar

Martin Gainty wrote:

With Postgres appears that TEXT is preferred over varchar(N)
http://archives.postgresql.org/pgsql-general/2006-03/msg01522.php

Implementation-wise, they are exactly the same, modulo length checking.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.