An index is a data structure that allows faster look ups, by creating a sorted version of one or more columns.
One table can only be sorted for one column, but with indexes it's possible to sort any columns.
An index reduce the look up time from O(N) to O(log2N), because the operation doesn't traverse the entire list but a binary tree. On the other hand, a writing operation must update the indexes, slowing down this kind of operations. Having indexes also mean more storage space required.
Normally the primary keys are indexed by default. Further indexes are convenient when most of the searches are performed on non-key fields.
An index can't usually be seen.
This is the syntax to create a new index:
CREATE index index_name ON Orders(first_column_name, second_column_name);
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.