Question: So I was reading up on indexes and their implementation, and I stumbled upon this website that has a brief explanation of b-tree indexes:

<http://20bits.com/articles/interview-questions-database-indexes/>

The b-tree index makes perfect sense for indexes that are only on a single column, but let's say I create an index with multiple columns, how then does the b-tree work? What is the value of each node in the b-tree? 

For example, if I have this table:

```
table customer:
id    number
name   varchar
phone_number   varchar
city   varchar

```

and I create an index on: (id, name, city) 

and then run the following query:

```
SELECT id, name 
  FROM customer
 WHERE city = 'My City';

```

how does this query utilize the multiple column index, or does it not utilize it unless the index is created as (city, id, name) or (city, name, id) instead?

Answer: 
With most implementations, the key is simply a longer key that includes all of the key values, with a separator. No magic there ;-)

In your example the key values could look something like

```

"123499|John Doe|Conway, NH"
"32144|Bill Gates| Seattle, WA"

```

One of the characteristics of these indexes with composite keys is that the intermediate tree nodes can be used in some cases to "cover" the query.

For example, if the query is to find the Name and City given the ID, since the ID is first in the index, the index can search by this efficiently. Once in the intermediate node, it can "parse" the Name and City, from the key, and doesn't need to go to the leaf node to read the same.

If however the query wanted also to display the phone number, then the logic would follow down the leaf when the full record is found.
In Oracle a composite key index can be used even though the leading columns are not filtered. This is done through three mechanisms:

1. A fast full index scan, in which multiblock reads are used to traverse the entire index segment.
2. An index full scan, in which the index is read in the logical order of the blocks (I believe I read that in recent versions Oracle can use multiblock reads for this, but really you should count on single block reads)
3. An inddex skip scan, where a very low cardinality for the non-predicated leading columns allows Oracle to perform multiple index range scans, one for each unique value of the leading column(s). These are pretty rare in my experience.

Look for articles by Richard Foote or Jonathan Lewis for more information on Oracle index internals.