Solved

Oracle Index on table with 50 rows increase performance?

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

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.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
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…

778 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