View previous topic :: View next topic
|
Author |
Message |
saurabh39 Warnings : 1 Active User
Joined: 11 Apr 2008 Posts: 144 Location: Jamshedpur
|
|
|
|
Hi All,
Recently I was reading a article on B Tree structure for a index. The article was dealing with a case where index is defined on one column. I want to know what will the B Tree structure look like, if we have say index on 4 cloumn and in which case the DB2 will have matching index scan or non matching.
Any pointers to article on composite index? |
|
Back to top |
|
|
mtaylor
Active User
Joined: 20 Feb 2009 Posts: 108 Location: Kansas City
|
|
|
|
It's not hard to imagine that in each non leaf node, where there was a single value indicating the max value in the associated leaf/node, there are four values for each of the four columns and a comparison function that compares each of the four values on some lexographical ordering based on ascending/desending.
But google doesn't readily return any useful links and I've not taken a database implementation course so that's just speculation. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Google on "composite index" and btree will give some information
to think about. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Possibly an oversimplification, but you might consider a composite index as an index_value rather than multiple columns values.
We (people rather than the machines) are aided by seeing the "pieces". The system doesn't need them really.
The values used in the btree are the index_value. I believe if you look at the article again substituting the index_value for the "one column" you will have what you are looking for.
And i may have misunderstood the question. . . |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Saurabh,
You might want to take a look at this .
Sushanth |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
As dick said : it's just a concatenation of 4 columns. an index on a char(16) will look exactly the same as one on 4 char(4) columns.
In DB2 LUW there is a concept of INCLUDE columns on unique indexes.
Suppose you have a unique index on 3 columns, but like to add a fourth to make your accesspath index-only.
On z/os you can not use that index without sacrificing your unique constraint on the first 3 columns. On LUW you can.
For these kind of indexes it is true that only the first 3 columns are on the non-leaf pages of the index, and on the leaf-pages all 4 cols are present. thus enforcing uniqueness and keeping smaller B-tree. |
|
Back to top |
|
|
|