Re: Need theory/comprehension help on Multi-Column indexes

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Need theory/comprehension help on Multi-Column indexes
Дата
Msg-id 6EE64EF3AB31D5448D0007DD34EEB3412A7590@Herge.rcsinc.local
обсуждение исходный текст
Ответ на Need theory/comprehension help on Multi-Column indexes  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-hackers
> Folks,
>
> I've been poking around the indexing code, and I really don't
understand
> the
> page structure and splittng/branching for multi-column BTree indexes.
> I've
> looked in a couple DB textbooks to get a theoretically underpinning of
the
> structure of multi-column indexes, but none of the ones I've seen
cover
> them.
> Can someone help me out?

Heh. You haven't done much programming in COBOL. The basic idea is to
combine the multiple fields in a sequence of bytes (reversible into the
original fields) and do a straight strcmp()                    int  c(6) n(2)
So you have key k on t(f1, f2, f3)
And do an insert to t(1, 'abc', 44)
The datum******* **
"00000001  abc44" gets applied to the index.  The values below the stars
are the lowest values supported by that particular type.  The
requirement being that for a type to be indexible it must have able to
be mutated into a fixed length string.

At least, that is the simple way to do it.  It is also possible to
create an index using discreet fields and the type's built in Boolean
comparison.  This is more complicated, for example to find out if
t(a,b,c) > t(a1,b1,c1)
You have to check
a >= a1 and
(a > a1 or b >= b1) and
(a > a1 or b > b1 or c > c1)
or the Boolean reverse of the above:
a > a1 or
(a >= a1 and b > b1) or
(a >= a1 or b >= b1 or c > c1)

The above expression would have to be applied to generate a comparison
between an input value and a stored key value.
Merlin




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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Final call for translation updates
Следующее
От: "Serguei A. Mokhov"
Дата:
Сообщение: Re: Final call for translation updates