LoginSignup
22
22

More than 5 years have passed since last update.

MySQLでのサブクエリ、inner joinのパフォーマンス比較

Posted at

MySQLでサブクエリを作ると非常に遅くなることがあります。これは、外部クエリが評価された後、内部クエリが評価されるためです。
Inner Joinの場合、最適化されて遅くはなりません。

実際比較を行ってみた結果です。

256件のデータで
INNER JOIN: 0.002秒
サブクエリ: 0.348秒
と大きな違いがありました。

実行可能コード: https://paiza.io/projects/WmL_8SwUE-0G3Yx0KcJR4A

スクリーンショット 2014-12-19 午後4.56.51.png

22
22
1

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
22
22