varchar or text

From: Pascal Cohen <pcohen(at)wimba(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: varchar or text
Date: 2008-04-28 13:55:36
Message-ID: 4815D758.30408@wimba.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello
I had a look in previous posts in the forum but could not find the
answer I was looking for.
My question is should I switch from varchar to text.
We have "discovered" although it seems to be SQL that adding something
like 'text ' to a varchar(50) just silently cut the text
while a text with check(length) - or also a varchar with a check raised
an error.
I was suggested to replace varchar(255) with text when we have no idea
on the default length we would define or if we do not want a threshold.
In that case I was thinking about being homogeneous and using text
everywhere adding check where necessary.
I would remove the space strange behavior and would be homogeneous.
I also read the perfs are identical with text and varchar.

My main concern is that if I don't set any check to a text field, it can
be 1Gb large which is a bit tto big to me. Anyway I can't imagine
updating my whole database replacing varchar(255) with text + checks
everywhere. That would make my schema less readable with many checks
where today with \d my display is compact.
I don't know what would be the best ? Keep varchar and live with the
space behavior. Move to text and add checks but the 1Gb limit scares me
a bit.

Thanks for advice or help.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pascal Cohen 2008-04-28 13:56:50 Re: Deny creation of tables for a user
Previous Message Martin Marques 2008-04-28 12:27:17 meaning of default_statistics_target