in reply to Excessive execution time passing parameters to Oracle
You can force Oracle to use specific indexes or join methods using hints. It's been a couple of years since I've done heavy Oracle work, but I think it's possible that the 'between' may not use the indexes if it doesn't know how many values it's going to return (as if its returns more than 5-20% (number dependant on oracle version) of the table, it's going to be faster to do a full table scan for a typical table) Generating histograms can help, but if you have skewed data, the optimizer won't know the best situation for the bind variables.
One thing that looks odd to me is that you've got two ranges on the same table, with a different status flag -- if they are the same range, I'd suggest instead using:
WHERE ( rec_status IN ( 'A', 'I' ) AND ucsiiu_receipt_at_mot_dt BETWEEN TO_DATE( ?, 'mm/dd/yy') AND TO_DA +TE( ?, 'mm/dd/yy' ) )
(if they were the same range, Oracle could sort it out when it generates the execution plan ... if it couldn't, it has to do two queries, then merge them, which might mean a sort-merge, which is very slow for large sets)
If this is a common query, you might also make a special index for it, that contains both columns.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Excessive execution time passing parameters to Oracle
by Anonymous Monk on Sep 26, 2006 at 09:45 UTC | |
by jhourcle (Prior) on Sep 27, 2006 at 15:19 UTC | |
by Anonymous Monk on Sep 26, 2006 at 09:52 UTC |