複合インデックスとは?
複合インデックスは、特定の順序で2つ以上のカラムに構築された単一のインデックスです。インデックスはそれらのカラムの先頭のプレフィックスでフィルタリングするクエリには役立ちますが、最初のカラムをスキップするクエリには役立たないため、順序が重要です。一般的なクエリパターンに合わせてカラムの順序を選ぶことが、その有用性の鍵となります。
なぜ重要か
適切に順序付けられた複合インデックスは、複数の単一カラムインデックスの代わりに、1つの構造で複数条件のクエリを満たせます。カラムの順序を誤ると、高速化したかったクエリに対してインデックスが使われないままになります。
関連ガイド
What Is a Database Index?A database index is an auxiliary data structure that lets the engine find rows matching a query quickly, avoi…
What Is a Covering Index?A covering index contains every column a query needs, so the engine can answer it from the index alone withou…
What Is a Query Plan?A query plan is the step-by-step strategy a database chooses to execute a SQL statement, including which inde…