Solved

Oracle Index on table with 50 rows increase performance?

Posted on 2010-11-18
5
306 Views
Last Modified: 2012-05-10
A table that looks like this with 50 records for each state:

Table: STATE_CODES
   state_code_id number,
   state_code     varchar2(2)

Is there a performance gain adding an index to state_code column when executing the query like below?

     select state_code_id from state_codes where state_code = 'FL';

The real questions is, in Oracle, is there a threshold where an index shouldn't be used if there # rows in the table are below a certain value?  Is there any documentation for Oracle that discusses this?
0
Comment
Question by:ciphersol
5 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34166021
An index on this table will not gain you any performance and will likely be ignored by the Cost-Based Optimizer (COB) since the entire table will probably be in an Oracle block or two.

You can 'try' is and see by looking at explain plans with and w/o the index.  You might also look at creating the table as index-organized.  That might help a little with performance but you'll need to test to see.

I'll see if I can find a link that might help explain this.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 125 total points
ID: 34166099
actually they CAN be helpful.  -basic idea is indexes have a more organized structure  than tables.  So the optimizer can find rows faster in an index than it can in a table.  Even if the table is 1 block!

very good discussion here.

http://en.wordpress.com/tag/small-indexes/

also note,  indexes are required in order to enforce unique constraints.

So, if you want to be sure there aren't two states with code "FL"  you will need a constraint, which means you will need an index.
0
 
LVL 14

Expert Comment

by:ajexpert
ID: 34166214
If you are using Oracle 11g, you can test the performance by creating invisible index on state_code

More information on invisible indexes:

http://oracletoday.blogspot.com/2007/08/invisible-indexes-in-11g.html
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34166224
Good link.  now I don't have to find one.

But unless you are a massive OLTP/Datawarehouse or your hardware is so pressed for resources that you need to account for every single 'get', isn't this technically an academic exercise from a performance perspective?

I do agree that an index from a constraint standpoint is very useful.

0
 

Author Comment

by:ciphersol
ID: 34166328

All very good information.  

This confirmed what I thought but I was having a difficult time finding this information on the internet.

Thanks ststuber.

Also, I didn't know about invisible indexes so thanks ajexpert.

slightwv, in my case I was performing a data migration and it was hitting the table a lot so it could add a slightly beneficial performance increase.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question