Don't use ORM's naively.
Be careful about what you call in a loop.
Those three alone account for most of the execution speed issues I've encountered. And they're all low-hanging fruit.
Don't use ORM's naively.
Be careful about what you call in a loop.
Those three alone account for most of the execution speed issues I've encountered. And they're all low-hanging fruit.
This would matter a lot only if those if statements were in a bottleneck of the program, e.g. in a loop or nested loop that ran a high number of times. (Unless you are trying to squeeze out the last few cycles of performance). Or am I getting you wrong?
isn't it put the most probably true condition first?
A and B
and B and A
You want to compare expected execution times, which are: E(A) + p(A) E(B)
(E(X) =expected execution time of X, p(X) = probability that X evaluates to true) and E(B) + p(B) E(A)
The first is larger if (1 - p(B)) E(A) > (1 - p(A)) E(B)
End result is that it may be better to put the expensive call first, if the probability of the cheap call being true is much higher than that of the expensive call.[Feel free to extend this model by adding the time needed to make or not make the branch around the second part]
In practice, if one is a function call and the other is not, put the function call last, then, if performance is inadequate, measure.