0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SQLの評価順序

Posted at

SQLの高速化

SQLのパフォーマンスに問題があって、チューニング必要という場面はよくあります。
エンジニアの皆さんに役立つtipsではなく、基礎理論をまとめていこうと思います。

SQLの評価順序

  1. FROM
  2. ON
  3. JOIN
  4. WHERE
  5. GROUP BY
  6. SUM, AVGなどの関数
  7. HAVING
  8. SELECT, UNION
  9. DISTINCT
  10. ORDER BY
  11. LIMIT

SQLを書くときもこの順序で書くと、より効果的な成果を上げられるかもしれません。
またHAVING句で絞るよりもWHERE句で絞った方が効果的であることもわかります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?