Execution order of conditions in SQL 'where' clause

后端 未结 6 1363
温柔的废话
温柔的废话 2020-12-06 05:31

I have a set of conditions in my where clause like

WHERE 
d.attribute3 = \'abcd*\'  
AND x.STATUS != \'P\' 
AND x.STATUS != \'J\' 
AND x.STATUS != \'X\' 
AND         


        
6条回答
  •  遥遥无期
    2020-12-06 06:13

    Finally, relational database theory says that you can never depend on the order of execution of the query clauses, so best not to try. As others have said, the cost-based optimizer tries to choose what it thinks is best, but even viewing explain plan won't guarantee the actual order that's used. Explain plan just tells you what the CBO recommends, but that's still not 100%.

    Maybe if you explain why you're trying to do this, some could suggest a plan?

提交回复
热议问题