Обсуждение: MAIN vs. PLAIN

Поиск
Список
Период
Сортировка

MAIN vs. PLAIN

От
"Dave Held"
Дата:
I notice that by default, postgres sets numeric fields to
storage MAIN.  What exactly does that mean?  Does that mean
it stores it in some type of compressed BCD format?  If so,
how much performance gain can I expect by setting the storage
to PLAIN?  Also, the docs say that char(n) is implemented more
or less the same way as text.  Does that mean that setting
a field to, say, char(2) PLAIN is not going be any faster
than text PLAIN?  That seems a bit counter-intuitive.  I
would hope that a char(2) PLAIN would just reserve two chars
in the record structure without any overhead of pointers to
external data.  Is there a reason this isn't supported?

__
David B. Held
Software Engineer/Array Services Group
200 14th Ave. East,  Sartell, MN 56377
320.534.3637 320.253.7800 800.752.8129

Re: MAIN vs. PLAIN

От
Tom Lane
Дата:
"Dave Held" <dave.held@arrayservicesgrp.com> writes:
> I notice that by default, postgres sets numeric fields to
> storage MAIN.  What exactly does that mean?

See http://developer.postgresql.org/docs/postgres/storage-toast.html

There isn't any amazingly strong reason why numeric defaults to MAIN
rather than EXTENDED, which is the default for every other toastable
datatype --- except that I thought it'd be a good idea to have at
least one type that did so, just to exercise that code path in the
tuple toaster.  And numeric shouldn't ordinarily be large enough to
need out-of-line storage anyway.  It's unlikely even to need
compression, really, but as long as it's a varlena type the overhead
to support toasting is nearly nil.

            regards, tom lane