| Introduction to Database Indexes | |
By Chris Smith |
Published
02/15/2006
|
Programming
|
Rating:
![]() ![]() ![]() ![]()
|
|
|
Multi-Column IndexesWe could create an index like this: CREATE INDEX news_cats ON newsitem_categories(newsid, categoryid); However, doing this limits some ways the index can be used. A query against the table that uses both 'newsid' and 'categoryid' will be able to use this index. A query against the table that only gets the 'newsid' will be able to use the index. A query against that table that only gets the 'categoryid' will not be able to use the index. For a table like this: CREATE TABLE example ( a int, b int, c int ); With this index: CREATE INDEX example_index ON example(a,b,c);
SELECT a,b,c FROM example where a=1 OR b=2;
|
|
or 02-9262-7770 


