Say I placed a pillar that has actually a higher potential for uniqueness an initial or visa versa?
With a kind query optimiser: it shouldn"t.
You are watching: The order of precedence for the logical operators in a where clause is
But in practice, I doubt it might.
You deserve to only tell because that your instances by measuring. And the measurements will likely change as the circulation of data changes in the database.
Richard - all questions have an answer. If that answer is unknown or the inquiry is not certain enough for an answer, you can request an ext info. To say "it shouldn't however it might" is not an answer. It's an extremely vague one at best.
For Transact-SQL there is a identified precedence for operators in the problem of the whereby clause. The optimizer might re-order this evaluation, so you shouldn"t depend on short-circuiting habits for correctness. The order is usually left come right, however selectivity/availability the indexes probably likewise matters. Simplifying her search condition should boost the capacity of the optimizer to manage it.
where (a OR b) and also (b OR c)could be simplified to
where b OR (a and also c)Clearly in this instance if the query deserve to be created to uncover if b holds first it may be able to skip the evaluation of a and c and thus would certainly run faster. Even if it is the optimizer deserve to do this simple revolution I can"t answer (it may be able to), however the suggest is the it more than likely can"t perform arbitrarily facility transformations and also you may be able to effect query power by rearranging your condition. If b is much more selective or has an index, the optimizer would likely be able to construct a query using it first.
EDIT: with regard to your question around ordering based on uniqueness, I would certainly assume that the any hints friend can carry out to the optimizer based upon your expertise (actual, no assumed) of the data couldn"t hurt. Pretend the it won"t do any kind of optimization and also construct her query as if you essential to define it from many to the very least selective, however don"t obsess about it till performance is in reality a problem.
See more: How Many Edges Does A Rectangular Prism Have ? Vertices, Edges, And Faces
Quoting indigenous the reference above:
The bespeak of precedence for the logical operators is not (highest), followed by AND, adhered to by OR. Parentheses have the right to be provided to override this precedence in a search condition. The stimulate of review of reasonable operators can vary depending on selections made through the ask optimizer.