Albe Laurenz <laurenz.albe@wien.gv.at> writes:
> The only useful thing about varchar is that it imposes a length constraint on a database field.
> Values used for indexing have a length limit, so if you change an indexed column to text
> somebody could try to insert values that will cause errors because the limit has been exceeded.
I'm not particularly buying that argument. If you insert an overlength
field value, you will get an error either way; it's just spelled
differently. Also, using varchar(N) isn't a particularly efficient way to
guard the btree length limit, because N is measured in characters but the
btree length limit is in bytes. You'd have to use a very conservatively
small N to be absolutely sure you don't get a btree error, and that would
result in throwing some errors that actually weren't necessary at all.
> Also you application code cannot rely on a certain size limit any more.
This is a valid argument, though again only to the extent that you need a
size limit measured in characters not bytes.
regards, tom lane