Solved

Oracle Index on table with 50 rows increase performance?

Posted on 2010-11-18
5
300 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)
Comment Utility
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
Comment Utility
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
Comment Utility
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)
Comment Utility
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
Comment Utility

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

743 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

17 Experts available now in Live!

Get 1:1 Help Now