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

From Joe
Subject Re: Converting MySQL tinyint to PostgreSQL
Date
Msg-id 42D42F34.40809@freedomcircle.net
Whole thread Raw
In response to Re: Converting MySQL tinyint to PostgreSQL  (Dawid Kuroczko <qnex42@gmail.com>)
Responses Re: Converting MySQL tinyint to PostgreSQL
Re: Converting MySQL tinyint to PostgreSQL
List pgsql-general
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.

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"?

Joe


pgsql-general by date:

Previous
From: mail TechEvolution
Date:
Subject: export/import database
Next
From: Tom Lane
Date:
Subject: Re: Converting MySQL tinyint to PostgreSQL