From: | Manfred Koizar <mkoi-pg(at)aon(dot)at> |
---|---|
To: | ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Alternative variable length structure |
Date: | 2005-09-09 11:07:41 |
Message-ID: | d4r2i11e99hikuupl2e345dm7o18v1tn8d@email.aon.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 08 Sep 2005 18:02:44 +0900, ITAGAKI Takahiro
<itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
+ * The length of varlena2 is encoded as follows:
+ *
+ * | First | Trailing | Total | Max |
+ * | byte | bytes | bits | length |
+ * +----------+----------+-------+---------+
+ * | 0******* | 0 | 7 | 127 |
+ * | 10****** | 1 | 14 | 16K -1 |
+ * | 110***** | 2 | 21 | 2M -1 |
+ * | 1110**** | 3 | 28 | 256M -1 |
+ * | 1111---- | 4 | 32 | 4G -1 |
With external and compression flags this would look like
* | ec0***** | 0 | 5 | 31 |
* | ec10**** | 1 | 12 | 4K -1 |
* | ec110*** | 2 | 19 | 512K -1 |
* | ec1110** | 3 | 26 | 64M -1 |
* | ec1111-- | 4 | 32 | 4G -1 |
Only a matter of taste, but I'd just waste one byte for sizes between 4K
and 512K and thus get a shorter table:
* | ec0***** | 0 | 5 | 31 |
* | ec10**** | 1 | 12 | 4K -1 |
* | ec110*** | 3 | 27 | 128M -1 |
* | ec111--- | 4 | 32 | 4G -1 |
And you get back that one byte for sizes between 64M and 128M :-)
Another possible tweak:
* | 0******* | 0 | 5 | 127 |
* | 1ec0**** | 1 | 12 | 4K -1 |
* | 1ec10*** | 3 | 27 | 128M -1 |
* | 1ec11--- | 4 | 32 | 4G -1 |
I.e. drop the flags for very short strings. If these flags are needed
for a string of size 32 to 127, then use a two byte header.
Servus
Manfred
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2005-09-09 11:55:12 | statement_timeout logging |
Previous Message | Martijn van Oosterhout | 2005-09-09 10:54:00 | Re: Case insensitive indexing in posgtres? |