On 7/12/05, Joe <svn@xxxxxxxxxxxxxxxxx> 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 ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your message can get through to the mailing list cleanly