Posted by : Akshay Patil Thursday, 16 April 2015

What is Index?

  • Allows users to quickly locate specific records.
  • It is a performance-tuning method that is used to speed up retrieval of records by using a pointer. 
  • An index creates an entry for each value that appears in the indexed columns. By default, Oracle creates B-tree indexes.
  • Can reduce disk I/O by using rapid path access method to locate the data quickly.
  • Is independent of the table it indexes.
  • Indexes can be created on a single column or a group of columns. When a index is created, it first sorts the data and then it assigns a ROWID for each row. 
  • The users cannot see the indexes, they are just used to speed up searches/queries.
How Are Indexes Created?
Automatically: A unique index is created automatically when you define a PRIMARY KEY or UNIQUE constraint in a table definition.
Manually: Users can create non - unique indexes on columns to speed up access time to the rows.

Creating an Index :

Syntax : 
CREATE INDEX index_name ON table (column[, column]...);
Example : 
CREATE INDEX idx_cust_id_ ON customers_info (customer_id);
/*---Index Created.---*/
When To Create Index?
  • The column is used frequently in the WHERE clause or in a join condition.
  • The column contains a wide range of values.
  • The column contains a large number of null values.
  • Two or more columns are frequently used together in a WHERE clause or a join condition.
  • The table is large and most queries are expected to retrieve less than 2–4% of the rows.
When not to create Index?
  • The table is small.
  • The columns are not often used as a condition in the query.
  • Most queries are expected to retrieve more than 2–4% of the rows.
  • The table is updated frequently.
Removing an Index

Remove an index from the data dictionary.
DROP INDEX index;
Remove the EMP_ENAME_IDX index from the data dictionary.
DROP INDEX idx_cust_id;/* Index dropped. */
To drop an index, you must be the owner of the index or have the DROP ANY INDEX privilege.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Study Basics

Oracle APEX Oracle SQL Oracle PL/SQL

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

Unordered List

Follow us on Facebook!

- Copyright © TechnicalBits -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -