Skip to content
Advertisement

Oracle Optimize Query

i’m working with oracle pl/sql and i have a stored procedure with this query, and it is a bit convoluted, but it gets the job done, the thing is it takes like 35 minutes, and the sql developer Autotrace says that is doing a full scan even though the tables have their indexes.

So is there any way to improve this query?

Thanks.

Advertisement

Answer

Change this:

To this:

Instead of building a function-based index you can modify the predicate to be sargable (able to use an index). Instead of using TRUNC to subtract from the the column, add a day minus one second to upper bound literal.

The code is more confusing but should be able to take advantage of the index. However, 35 days of data may be a large amount; the date index may not be very useful and you may need to look at other predicates.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement