sql - NULL Value Substitution on constant -


For fun, I'm playing today with the built-in adapter for Audal In Todd. One optimization recommended,

  and emp.pay_type = NVL ('ft', uid)  

instead

 < Code> and emp.pay_type = 'ft'  

I'm confused because of what is happening here and why, but also confused on why it will improve performance. Since there is a string within the FT SQL query and therefore never tap, why does it matter? I think this area has something with the current index, but Oracle is unable to do anything in the docks.

This is a strange advice that the NVL function works like this:

  NVL (XP1, Val 1)  

If 'exp1' is not zero, then it comes back; Otherwise 'val1' is returned.

Because in the example 'FT' can not be tap, there is no benefit to using the NVL function, and a small display penalty (at least for the adapter, NVL is redundant, Perhaps the execution penalty if the adapter does not work that NVL is useless).

If read the situation:

and emp.pay_type = NVL ("FT", UID)

Then there can be a benefit; Here we have a delimited identifier (name of the column enclosed in double quote) and column value may be zero; The NVL call ensures that the tap is returned only when "FT" is the tap and is the UID tap UID is definitely a regular identifier.

This situation can be done if you read the situation:

  and emp.pay_type = NVL (UID, 'FT')  

Now if the UID value is null, then a default value 'FT' is used as this pay type.


Comments