SQL - Does the order of WHERE conditions matter?

前端 未结 5 1573
误落风尘
误落风尘 2020-11-29 06:49

Assume that category_id is an index key (not primary key) of table books. Is there any difference between the following two SQL statements?

5条回答
  •  独厮守ぢ
    2020-11-29 07:49

    Yes, SQL is a declarative language. But in SQL Server (not sure about other engines) a DBA can actually (kinda) do this, by forcing an execution plan in SQL Query Store.

    But, yeah, you can't control it from your app, or from within the query text itself.

    P.S. 2 more cents: you can control the order of JOIN's by using FORCE ORDER.

提交回复
热议问题