Alex Rivera | Logout

How to choose and optimize oracle indexes?

Asked 2008-10-17T14:01:59.233
35

I would like to know if there are general rules for creating an index or not. How do I choose which fields I should include in this index or when not to include them?

I know its always depends on the environment and the amount of data, but I was wondering if we could make some globally accepted rules about making indexes in Oracle.

Edit
Report

1 Answer

0

Usually one puts the ID columns up front and those usually identify the rows uniquely. A combination of columns can also do the same thing. As an example using cars... tags or license plates are unique and qualify for an index. They (the tags column) can qualify for the primary key. The owners name can qualify for an index if you are going to search on name. make of car really shouldn't get an index in the beginning as it's not going to vary too much. Indexes don't help if the data in the column doesn't vary too much.

Take a look at the SQL - what are the where clauses looking at. Those may need an index.

Measure. What is the issue - pages/queries taking too long ? what's being used for the queries. Create an index on those columns.

Caveats: indexes need time for updates and space.

and sometimes full table scans are quicker than an index. small tables can be scanned quicker than getting the index and then hitting the table. Look at your joins.

answered 2008-10-17T14:14:33.467

Your Answer