Re: How to find greatest record before known values fast

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrus <kobruleht2(at)hot(dot)ee>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to find greatest record before known values fast
Date: 2014-10-03 23:15:58
Message-ID: 542F2E2E.7020900@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/03/2014 03:59 PM, Tom Lane wrote:
> Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
>>> page 28:
>>>
>>> Unlike many
>>> databases, char(n) is NOT stored as afixed-sizedfield
>>> in Postgres. It is treated exactly the sameas
>>> varchar(n)except for being padded
>
>> Which directly contradicts the information on page 27:
>
> This info is probably not as well worded as it could be, but it's not
> really wrong. The key point is that char(N) is blank-padded (thereby
> wasting space) to be N *characters*, but that is not necessarily N
> *bytes*, because of possible multi-byte characters. Therefore the engine
> has to treat it as a variable-length datatype.

Well that is a distinction I had missed, thanks for the heads up. So the
bottom line is char(N) is variable length, but for values that do not
reach length N will require more storage space then varchar(n).

>
> I believe in some some other DBMSes, char(N) means N *bytes* and is
> treated as a fixed-size datatype. Dunno what they do with multibyte
> encodings.
>
> regards, tom lane
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andy Colson 2014-10-04 02:28:43 Re: Processor usage/tuning question
Previous Message Tom Lane 2014-10-03 22:59:36 Re: How to find greatest record before known values fast