Home » RDBMS Server » Performance Tuning » What are the best practices with indexes?
What are the best practices with indexes? [message #485882] Fri, 10 December 2010 15:17 Go to next message
DataMouse
Messages: 31
Registered: December 2010
Location: New York, NY - United Sta...
Member
So I was reading about indexes here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#i5671

Is there any reason to NOT use an index? If there aren't, then should you use an index on every column on every table?

What is the general best practice with indexes?

After reading the section, it seems that there are only positive impacts of using an index, so why are they not automatically created?

Thanks!
Re: What are the best practices with indexes? [message #485885 is a reply to message #485882] Fri, 10 December 2010 15:28 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
DataMouse wrote on Fri, 10 December 2010 21:17

After reading the section, it seems that there are only positive impacts of using an index, so why are they not automatically created?

Because they take disk space. Because oracle has to modify them whenever you do dml on related data thus slowing it down. Because they aren't always useful.

DataMouse wrote on Fri, 10 December 2010 21:17

Is there any reason to NOT use an index?

If you need to retrieve a large proportion of the data from a table using an index becomes less effiecient then just reading the table directly and oracle will just ignore the index in these cases.
Think of them in the same way as the index in a text book or encyclopedia - if you want to look up a couple of things you'll use the index to find them, if you want to read a whole chapter or more you won't bother with it.

DataMouse wrote on Fri, 10 December 2010 21:17

What is the general best practice with indexes?


Index selective columns that are used in the where clauses of a lot of queries. Don't bother with anything else unless you find a slow query that you determine would be improved with an index.
Re: What are the best practices with indexes? [message #485886 is a reply to message #485885] Fri, 10 December 2010 15:34 Go to previous messageGo to next message
DataMouse
Messages: 31
Registered: December 2010
Location: New York, NY - United Sta...
Member
Awesome! Thanks. I wish there was one of those "This post was helpful" buttons.
Re: What are the best practices with indexes? [message #485909 is a reply to message #485886] Sat, 11 December 2010 03:48 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Not really a "post", but the whole "topic":

/forum/fa/8526/0/

Previous Topic: Query using rownum in where cluase with millions of records
Next Topic: SID column in V$SESSION
Goto Forum:
  


Current Time: Sat Apr 27 21:42:38 CDT 2024