Code Analysis: Rule 4207

Rule 4207 Consider resequencing conditional logic for better performance.

I would the sequence to be ok, how does this rule work?

BEGIN
IF( my_var IS NULL OR some_expensive_test( my_var ) ) THEN – Rule 4207 Consider resequencing conditional logic for better performance.
NULL;
END IF;
END;

I would assume it checks the existence of the OR (or AND) in an IF statement. Those should always be looked at to be more efficient. The fact that your code is so simple (my_var IS NULL) is not part of the condition.

From: Peter Lang [mailto:bounce-PeterLang@toadworld.com]

Sent: Wednesday, 25 May, 2016 10:38

To: toadoraclebeta@toadworld.com

Subject: [Toad for Oracle - Beta Discussion Forum] Code Analysis: Rule 4207

Code Analysis: Rule 4207

Thread created by Peter Lang

Rule 4207 Consider resequencing conditional logic for better performance.

I would the sequence to be ok, how does this rule work?

BEGIN

IF( my_var IS NULL OR some_expensive_test( my_var ) ) THEN – Rule 4207 Consider resequencing conditional logic for better performance.

NULL;

END IF;

END;

To reply, please reply-all to this email.

Stop receiving emails on this subject.

Or
Unsubscribe from Toad for Oracle - Beta Forum
notifications altogether.

Toad for Oracle - Beta Discussion Forum

Flag
this post as spam/abuse.

Wim de Lange

Senior IT expert

ALcontrol Laboratories

Steenhouwerstraat 15

3194 AG Rotterdam NL

Tel +31 10 23 14 724 • Mobile +31 65 15 34 387

Fax +31 10 41 63 034

e-mail W.deLange@alcontrol.nl •
www.alcontrol.com

  • The information in this e-mail is confidential and may also be legally privileged.The contents are intended for recipient only and are subject to the legal notice available at: www.alcontrol.nl. Registered Office:Alcontrol BV, Steenhouwerstraat 15, 3194 AG Rotterdam.*

Here’s our internal description of what this rule is supposed to do:

“Since the PL/SQL expression evaluator works from left to right, there are often expressions which can be resequenced or reordered such that the resulting expression is equivalent - but which can very often run quicker. The idea is to simply use expression evaluation rules of precedence to place the most expensive operators and operands at the deepest expression level - such that they may never need to be evaluated in order to resolve the expression (i.e. earlier sub-expressions may sometimes yield the result without the need to run the more expensive code).”

The actual code enforcing this rule is outdated, and it’s too hard to fix it. Instead, I queued a rewrite as XPath expression. (QP-1652)

Andre