Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Oracle Index on table with 50 rows increase performance?

Posted on 2010-11-18
5
Medium Priority
?
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

721 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