Re: [HACKERS] Tuple size - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] Tuple size
Date
Msg-id 5d0777a54355e751aa20559c59f0ff1a
Whole thread Raw
In response to [HACKERS] Tuple size  (Alexander Demenshin <aldem@techie.com>)
List pgsql-hackers
>
> Hi!
>
>   I have tried:
>
> create table tab (v1 char(4096), v2 char(4096), v3 char(4096));
>
>   Then:
>
> insert into tab values('1');
>
>   OK
>
> insert into tab values('1','2');
>
>   Tuple is too big: size 8256.
>
>   Well, I understand why, but type 'char' is *fixed* length type,
>   so even if I don't use some attributes, it *must* be inserted
>   with all spaces... At least, I expected this... In this case
>   I must get "tuple is too big" even if I will insert "empty"
>   record. It is not so - why?

NULL has zero length.

>
>   And one more: when I use 'varchar' without size, I get variable
>   length attribute similar to 'text', which is stored with actual
>   length, without padding. If I will specify length, it will be
>   stored without padding, but will occupy specified number of bytes
>   *always*, but, when retrieved, will return actual number of characters.
>   Why not store only actual length, even if maximum specified?
>   And, it will be listed as attribute with length zero, not 'var',
>   but *actually* it is variable length, same as 'text'...

It is just part of the way varchar works.  Performance is slightly
better with fixed-length strings like this, perhaps.

- --
Bruce Momjian
maillist@candle.pha.pa.us

------------------------------

pgsql-hackers by date:

Previous
From: Steve A Fink
Date:
Subject: Re: [HACKERS] Tuple size
Next
From: "Vadim B. Mikheev"
Date:
Subject: [HACKERS] Re: [PATCHES] SET DateStyle/get_token bug in v6.1