Re: Postgres advice for Java/Hibernate project

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Damian C" <jamianb(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Postgres advice for Java/Hibernate project
Date: 2006-06-19 02:23:24
Message-ID: 8950.1150683804@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Damian C" <jamianb(at)gmail(dot)com> writes:
> Question ONE: If we design a field (say) 50 characters long - and we
> have an instance/row using only (say) 20 characters - does Postgres
> "use" the whole 50, or only the 20??

Do you have a concrete reason to put a limit on the field width at all?
If not, don't. Use type text, or varchar without any particular length
limit. In any case, avoid type char(N), which is a historical hangover
that no longer has an excuse to live ...

> Question TWO: When following typical Hibernate examples we notice that
> String fields are typically specified with a length at a "binary
> boundary". So they seem to always be specified at 16, 32, 64, 128
> etc. Really the question should be "is a String length 17 (or 33 or
> 65) significantly slower to insert/search/retrieve than a String of
> length 16 (or 32 or 64)?".

Perhaps there's some database somewhere that cares, but Postgres
certainly doesn't. I rather doubt there's a reason for it on the Java
side either.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Damian C 2006-06-19 02:42:34 Re: Postgres advice for Java/Hibernate project
Previous Message John DeSoi 2006-06-19 02:05:17 Re: Postgres advice for Java/Hibernate project