Unix Technical Forum

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

This is a discussion on Re: Need theory/comprehension help on Multi-Column indexes within the pgsql Hackers forums, part of the PostgreSQL category; --> > Folks, > > I've been poking around the indexing code, and I really don't understand > the > ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 03:12 AM
Merlin Moncure
 
Posts: n/a
Default Re: Need theory/comprehension help on Multi-Column indexes

> 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




---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com