Singer Wang <swang@cs.dal.ca> writes:
> if I have a column that's gonna be between 5-300 charactors...
> should I go with a a charactor? varchar? or a text?
>
> what's the performance penalty going with a text instead of a
> varchar... or a char? I don't need to index it.... nor search based
> on it..
PostgreSQL's varchar and text are both based on the same internal
type. Varchar only limits the length of the string that can be
inserted. Char pads the strings with ' ' to the desired lengh. In
other words if I were to insert 'Jason' into a char(8) it would be
padded to 'Jason '.
In other words, use varchar if you have a hard limit that you want to
enforce, char if you want to guarantee string lengths, and text for
everything else.
Jason