Skip site navigation (1) Skip section navigation (2)

Re: Equivalent praxis to CLUSTERED INDEX?

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "J(dot) Andrew Rogers" <jrogers(at)neopolitan(dot)com>,"Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: <pgsql-performance(at)postgresql(dot)org>, <mischa(dot)sandberg(at)telus(dot)net>
Subject: Re: Equivalent praxis to CLUSTERED INDEX?
Date: 2004-08-26 19:30:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
>> How do vendors actually implement auto-clustering?  I assume 
>they move
>> rows around during quiet periods or have lots of empty space in each
>> value bucket.
>As far as I know, Oracle does it by having a B-Tree organized heap (a
>feature introduced around v8 IIRC), basically making the primary key
>index and the heap the same physical structure.  Any non-index columns
>are stored in the index along with the index columns.  Implementing it
>is slightly weird because searching the index and selecting the rows
>from the heap are not separate operations.

Almost the same for MSSQL. The clustered index is always forced unique.
If you create a non-unique clustered index, SQLServer will internally
pad it with random (or is it sequential? Can't remember right now) data
to make each key unique. The clustered index contains all the data
fields - both the index key and the other columns from the database.

It does support non-clustered indexes as well on the same table. Any
"secondary index" will then contain the index key and the primary key
value. This means a lookup in a non-clustered index means a two-step
index lookup: First look in the non-clustered index for the clustered
key. Then look in the clustered index for the rest of the data. 

Naturally a non-clustered index needs better selectivity before it's
actually used than a clustered index does.

IIRC, SQL Server always creates clustered indexes by default for primary



pgsql-performance by date

Next:From: Hervé PiedvacheDate: 2004-08-26 19:30:40
Subject: Re: TSearch2 and optimisation ...
Previous:From: Kevin BarnardDate: 2004-08-26 19:06:32
Subject: Re: Anyone familiar with Apple Xserve RAID

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group