I have the following SQL statement:
FUNCTION F1
INNER JOIN TABLE T1
INNER JOIN FUNCTION F2
INNER JOIN FUNCTION F3
INNER JOIN FUNCTION F4
...
INNER JOIN TABLE T2
In some situations, when it FUNCTION F1does not return any records, the wholes statement is executed for 12seconds.
Execution time FUNCTION F1(only) 4seconds. If I leave attached only FUNCTION F1, and the tables exectuin time again 4seconds.
So, SQL Server uses the rest of the functions that increase the execution time of the statement.
Why doesn't SQL Server skip execution because there is a clause INNER JOINand the first function returns nothing? Is there any way to fix this behavior?
gotqn source
share