Posted on 2011-09-09
Medium Priority
Last Modified: 2012-05-12
I have an INVOICE table with INV_NO as primary key with index.

Table also has ITEM_NO for the line items.

I normally select from table/view as this

SELECT col1,col2,... from INVOICE where INV_NO=p_inv_no
ORDER BY item_no.

Would it help to have the index replace by (INV_NO, ITEM_NO) or not since it is only used for sorting result set and not in the WHERE clause
Question by:sam15
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
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36514397
Set up something in your test system and see.

My gut feeling is it won't make any difference since it is not in the where.

I would need to set up my own tests to verify.
LVL 23

Assisted Solution

OP_Zaharin earned 800 total points
ID: 36515039
- to add further, if you want to experiment the index you've created. use EXPLAIN PLAN to see if the query use the index or not.
LVL 15

Expert Comment

ID: 36516029
Index on any Table do´nt grants order clause.
Note that on a String Key you have a character set at server side. Table index uses server character set.
The order clause uses Client character set.

You code seems respond to a Master-Detail query. Each time you change Primary record you get Child Rows.

A convenient solution for Detail record is the IOT Tables (Organization Index).
This requires a Primary key for the index  (INV_NO, ITEM_NO).
Advantages: all records from any key are contiguous on Disk. This save time on data retrieval.
It saves memory on Server as you get data olny from Table Segment, do´nt need get data from index segment.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 36516313
I tested it both ways and it did not seem to make a big difference but also my table does not have much data too. Both queries use the same index whether it is one column or two columns.

Index organized tables will index the whol tables and used mostly for lookup tables. This is a transactional table and there are 12 columns in it.

I really doubt that the ORDEr BY is using client character set too. This is SQL on server and run on server. Data is sent to client sorted and client just changes character set there if it is different.
LVL 77

Accepted Solution

slightwv (䄆 Netminder) earned 1200 total points
ID: 36529529
>>it did not seem to make a big difference but also my table does not have much data too

Like I mentioned, I didn't think it would.

>>Index organized tables will index the whol tables and used mostly for lookup tables.

Technically not.  IOTs store the non-indexed columns in the index blocks with the indexed columns.

For index lookups when you also return a large number of additional columns, it can reduce data block reads substantially.

It would probably be worth setting up tests for this as well.  Where it might cause problems is with other queries that also use the table.  They might slow way down.


Author Comment

ID: 36529695
IOT is similar to having a table with all columns indexed. I mainly use it for READ-ONLY lookup tables.
IOT table = One big index structure


This is TRANSACTION table that gets a lot of WRITES too and has MANY other columns.
 Since  all data is sorted before storage it might not be appropriate choice for this particular case.
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36530115
>>table that gets a lot of WRITES too and has MANY other columns

Probably not in this case.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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.
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 how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

649 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