Re: Postgres advice for Java/Hibernate project - Mailing list pgsql-novice

From Tom Lane
Subject Re: Postgres advice for Java/Hibernate project
Date
Msg-id 8950.1150683804@sss.pgh.pa.us
Whole thread Raw
In response to Postgres advice for Java/Hibernate project  ("Damian C" <jamianb@gmail.com>)
Responses Re: Postgres advice for Java/Hibernate project  ("Damian C" <jamianb@gmail.com>)
List pgsql-novice
"Damian C" <jamianb@gmail.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

pgsql-novice by date:

Previous
From: John DeSoi
Date:
Subject: Re: Postgres advice for Java/Hibernate project
Next
From: "Damian C"
Date:
Subject: Re: Postgres advice for Java/Hibernate project