Re: Converting MySQL tinyint to PostgreSQL - Mailing list pgsql-general

From Dawid Kuroczko
Subject Re: Converting MySQL tinyint to PostgreSQL
Date
Msg-id 758d5e7f0507130158342a68c9@mail.gmail.com
Whole thread Raw
In response to Re: Converting MySQL tinyint to PostgreSQL  (Joe <svn@freedomcircle.net>)
List pgsql-general
On 7/12/05, Joe <svn@freedomcircle.net> wrote:
> Dawid Kuroczko wrote:
> > smallint takes two bytes.  Numeric(1) will take around 10 bytes and char(1) will
> > take 5 bytes (4 bytes for length of data).
> I never would've imagined *that* amount of overhead for CHAR(1)!  I would've
> imagined that it would take up one byte (or two with a NULL indicator).  After
> all, we're not talking about VARCHAR(1) [which is sort of useless].  Don't the
> catalogs know the declared length and if so, why the length overhead?  I'm also
> surprised --albeit less-- about the NUMERIC(1) overhead.  Is any of this
> discussed in the Internals chapters?  I didn't see this discussed elsewhere.

It is all described in
http://www.postgresql.org/docs/8.0/interactive/datatype.html
with given above space requirements also.  Noone hides it, it's all black on
white. :-)

> As a perhaps-related aside, I've noticed several examples which declare string
> types as 'text', rather than VARCHAR or CHAR, the former being non-SQL standard.
> Is there some performance benefit to using 'text' (other than it being shorter
> to type :-) or is it just the "usual Postgres way"?

Some time ago people used text as a way for making "easily changeable varchar",
say:
col text CHECK (length(VAL) < 100)
...when person sees that 100 is too small it was just a matter of changing the
CHECK constraint.

...but it was long time ago, and since that time PostgreSQL is able to change
the type of column with no problems, and efficiently.

    Regards,
         Dawid

pgsql-general by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: illegal sort order
Next
From: "Evandro's mailing lists (Please, don't send personal messages to this address)"
Date:
Subject: NTFS partition autodetection during instalation