sql - Select "where clause" evaluation order -


When I have multiple parameters in SQL Server 2005, I guarantee that the evaluation order always is left From right?

Using an example:

Choose from the table where c = 1 and d = 2

If the "c = 1" status fails in this query, will the status of "d = 2" never be evaluated? PS-"C" is an integer indexed column, D is a large varchar and non-indexable column that requires a full table scan

Update I was trying to avoid execution of two questions or conditional statements, I just need a few things: if "condition" fails, one way of avoiding heavy "D" status Is because it is necessary in my case Is not.

There is no guarantee for evaluation order, the most effective way to execute adapter queries using the available information. Will try to find the way.

In your case, since C is indexed and D does not happen, the adapter should look at the pointer to find all the rows, which match the orbits in C, then those rows Get table data to evaluate the orbital on DD.

However, if it determines that the index on C is not very selective (although for your example, a penis column is hardly indexed), this decision to scan this table Can take.

In order to determine the execution order, you should be considered a plan for your query. However, it is up to the realization that the plan optimizer thinks that it is the best query at the right time.


Comments