If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Dense / Spares Indexes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-12, 06:52
Breako Breako is offline
Registered User
 
Join Date: Jan 2006
Posts: 119
Dense / Spares Indexes

Hi,
Does SqlServer have a concept of dense / sparse indexes?

And if so ho do I check how dense or how sparse the index is?

Thanks. info on dense / sparse indexes here: Database index - Wikipedia, the free encyclopedia

Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-07-12, 09:41
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
You can add a where clause to an index, and the index will only contain the values defined in that where clause. If you have a column that is 90% null values, you can index just the ones that have values:
Code:
create index ind_test on tablename (sparsecolumn) where sparsecolumn is not null
I have not tried this out myself, so I do not know how extravagant the where clause can get.
Reply With Quote
  #3 (permalink)  
Old 02-08-12, 04:25
Breako Breako is offline
Registered User
 
Join Date: Jan 2006
Posts: 119
Quote:
Originally Posted by MCrowley View Post
You can add a where clause to an index, and the index will only contain the values defined in that where clause. If you have a column that is 90% null values, you can index just the ones that have values:
Code:
create index ind_test on tablename (sparsecolumn) where sparsecolumn is not null
I have not tried this out myself, so I do not know how extravagant the where clause can get.
Thanks and how do I check if an index created some time ago is sparse or dense?
Reply With Quote
  #4 (permalink)  
Old 02-08-12, 09:23
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
Code:
 select object_name(object_id), name, filter_definition
 from sys.indexes
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On