Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modify query to use indexspace

Status
Not open for further replies.

ashimer2007

Programmer
Mar 13, 2008
2
IN
hi all,

i have a cursor with the where clause as

where

(trn_isin = :smx-isin

or

trn_isin = :ws-und-isin

or

trn_cusip = : smx-cusip )

here trn_isin is index ..

now the selection criteria is either of the 3 values should be present in the table

if im using the above where clause the query is going for a tablespace scan
maybe because of OR ... can anyone modify this query to do a indexspace scan ?

thanks,
ashimer
 
if need arise i can make trn_cusip as another index ..
IN predicate should work or else joins ..
 
Doing a table scan on this particular case is the best option.

Think about it.

The (trn_isin = :smx-isin or trn_isin = :ws-und-isin) on their own will be doing a index access, then a table access. However as you also have the other field which is not an index, even those entries that were excluded from a index access will need to have a table access to determine if the record should be included.

If you know that the percentage of records returned by either condition will be a small part of the total of the table, then creating another index on trn_cusip , and using a union (all) will probably be the best way to do it.
If on the other hand those 3 conditions mean that you will be getting 80% or more of the records, then table scan access is faster.


Even if you add the other index, doing the "where" on the same select would still only use one of them, or none. Union would be the only option to use BOTH indexes.

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top