Query/Index Usage Question

Posted by byoung2735 on 31-Jul-2018 08:58

Curious why this query results on a WHOLE-INDEX search on customer.cust-num?

find first customer where customer.name = if can-find( invoice where
invoice.invoice-num = 2 ) then "Jazz Futis Kauppa" else "Joe Customer" no-lock
no-error.


./fc.p ./fc.p 1 SEARCH sports.Customer Cust-Num WHOLE-INDEX

Thanks.

Posted by David Abdala on 31-Jul-2018 09:57

Because ABL does not have anything like "previous function evaluation".

The result of the function is unknown to ABL up to the evaluation, so it has to be evaluated for each customer. (can-find is a function).

Doing:

if can-find() then

name = "Jazz".

else

name = "Joe"

find first customer where customer.name = name no-lock no-error.

Should give you a different index usage.

All Replies

Posted by David Abdala on 31-Jul-2018 09:57

Because ABL does not have anything like "previous function evaluation".

The result of the function is unknown to ABL up to the evaluation, so it has to be evaluated for each customer. (can-find is a function).

Doing:

if can-find() then

name = "Jazz".

else

name = "Joe"

find first customer where customer.name = name no-lock no-error.

Should give you a different index usage.

This thread is closed