Question:
what is indexing in sql with exact description?
joan x
2006-07-20 19:48:49 UTC
clustering,non clustering
Four answers:
2006-07-20 19:51:56 UTC
what? i dont know what u mean.
falcon_
2006-07-21 08:34:55 UTC
Index improve the query performace. Assume you are frequently querying from a table called employee. So they primary key will be the employeeId that means your most of the query from this table have the where clause with the employee_id so if you create the index on this employee_id means the query will be in lightning speed. All these are considered as performance tunning if the data in a table is very huge. Below i give the definition for the Index





Index are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries.



Note: Updating a table containing indexes takes more time than updating a table without, this is because the indexes also need an update. So, it is a good idea to create indexes only on columns that are often used for a search.

A Unique Index



Creates a unique index on a table. A unique index means that two rows cannot have the same index value.



CREATE UNIQUE INDEX index_name

ON table_name (column_name)



The "column_name" specifies the column you want indexed.



A Simple Index



Creates a simple index on a table. When the UNIQUE keyword is omitted, duplicate values are allowed.



CREATE INDEX index_name

ON table_name (column_name)



The "column_name" specifies the column you want indexed.



Example

This example creates a simple index, named "PersonIndex", on the LastName field of the Person table:



CREATE INDEX PersonIndex

ON Person (LastName)



If you want to index the values in a column in descending order, you can add the reserved word DESC after the column name:



CREATE INDEX PersonIndex

ON Person (LastName DESC)



If you want to index more than one column you can list the column names within the parentheses, separated by commas:



CREATE INDEX PersonIndex

ON Person (LastName, FirstName)
rongenre
2006-07-21 05:11:17 UTC
Indexing means that your table maintains a data structure (like a b-tree) which maps values in the rows back to the addresses of the row. This speeds select speed, but costs a bit on update / insert.



A simple example is the primary key -- if you ask for a row by primary key it's really really fast, because the database knows right where to look for the row.



Indexes let keys which aren't primary (or even unique) act this way. It should take the search time from linear (O(N)) to at least log N, if not log 0 if the value is unique and it can maintain a hash instead of a btree.



This is totally recommended if you've got a database which isn't updated / inserted a lot, but you do queries on that particular key a lot. It will speed things up on a big table tremendously.
Rajesh K
2006-07-21 03:01:06 UTC
i can't get you friend. indexing in the sense...... i am presently learning SQL. I have'nt come across this


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...