Re: b-tree index search algorithms

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Samuel Vogel <s(at)muel-vogel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: b-tree index search algorithms
Date: 2012-07-18 21:56:32
Message-ID: 3066.1342648592@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Samuel Vogel <s(at)muel-vogel(dot)de> writes:
> Am 17.07.12 19:38, schrieb Tom Lane:
>> The datum values will be pointers to strings.

> I can simply dereference it and read all bytes until a null-byte appears
> (depending on the collation and that I know that it actually is a string)?

We use a length word and then data, with no trailing null, at least for
text and varchar. This area has been hacked for efficiency until it's
pretty complicated, but you can read about it in postgres.h.

> How would the b-tree know exactly that a value is only a reference? And
> even in that case you say that it could get the bits, but make no use of
> it, since it does not know what they represent, right?

It has access to the data type's basic storage parameters, which are
typbyval, typlen, and typalign; and we have standard conventions for
identifying the length etc of variable-length values. It's just the
meaning of the payload data bytes that's data-type-private.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mike Wilson 2012-07-18 22:39:31 Re: BUG #6733: All Tables Empty After pg_upgrade (PG 9.2.0 beta 2)
Previous Message Andrew Dunstan 2012-07-18 21:49:55 Re: bgwriter, regression tests, and default shared_buffers settings