Solved

TablleIndexColumns.

Posted on 2011-09-09
7
265 Views
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
0
Comment
Question by:sam15
7 Comments
 
LVL 76

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.
0
 
LVL 23

Assisted Solution

by:OP_Zaharin
OP_Zaharin earned 200 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.
0
 
LVL 15

Expert Comment

by:x77
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.
0
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.

 

Author Comment

by:sam15
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.
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 300 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.

0
 

Author Comment

by:sam15
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

http://www.orafaq.com/wiki/Index-organized_table

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.
0
 
LVL 76

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.
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

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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…
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.
This video shows how to recover a database from a user managed backup

762 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

20 Experts available now in Live!

Get 1:1 Help Now