Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Optimize query with function in where clause

lenoxJul 1 2015 — edited Jul 3 2015

Hi,

I have a query like this:

SELECT * FROM table_1 t

WHERE

(

-- Clause A (very long clause that filters a lot of rows)

)

AND f(t.field) = 'Y' -- This function is heavy but it should filter few rows

This query it's very slow because I think it tries to evaluate f() for every row in table_1.

Howerver if I query to database:

SELECT f(t.field) FROM table_1 t

WHERE

(

-- very long clause that filters a lot of rows

)

It's very fast.

How can I hint the query to filter rows by clause A and then by function?

Thanks in advance!

This post has been answered by John_K on Jul 3 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2015
Added on Jul 1 2015
26 comments
8,669 views