varchar vs text

Started by Sim Zacksover 21 years ago2 messagesgeneral
Jump to latest
#1Sim Zacks
sim@nospam.com

Are there any differences between text and varchar? I found the following in
the docs, which leads me to believe that there are no differences at all.
Can someone please confirm this before I switch all my varchars to text?

Tip: There are no performance differences between these three types, apart
from the increased storage size when using the blank-padded type. 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.

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Sim Zacks (#1)
Re: varchar vs text

On Tue, Jan 04, 2005 at 09:50:18AM +0200, Sim Zacks wrote:

Are there any differences between text and varchar? I found the following in
the docs, which leads me to believe that there are no differences at all.
Can someone please confirm this before I switch all my varchars to text?

Correct. The only difference between varchar and text is that varchar
can have a maximum length, which will be checked. As for storage used,
indexability, operators, etc they're identical.

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.