Re: Alternative variable length structure

Поиск
Список
Период
Сортировка
От Manfred Koizar
Тема Re: Alternative variable length structure
Дата
Msg-id d4r2i11e99hikuupl2e345dm7o18v1tn8d@email.aon.at
обсуждение исходный текст
Ответ на Alternative variable length structure  (ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp>)
Ответы Re: Alternative variable length structure  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Thu, 08 Sep 2005 18:02:44 +0900, ITAGAKI Takahiro
<itagaki.takahiro@lab.ntt.co.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.

ServusManfred


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Case insensitive indexing in posgtres?
Следующее
От: Simon Riggs
Дата:
Сообщение: statement_timeout logging