Solved

Oracle Index on table with 50 rows increase performance?

Posted on 2010-11-18
5
302 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 76

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 73

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 76

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
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.

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now