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?

DBのパフォーマンスのためのindex

0
Posted at

はじめに

どういう時に貼るかという判断を備忘録がてら残すため。

indexが有効なケース

  • テーブルの行数が多い(一万行以上)
  • 欲しい情報が全体の20%未満

indexが有効でないケース

  • カーディナリティが低い列の検索の場合
  • あいまい検索の場合
  • あと下記もききにくい
    • NULLを条件とする検索
    • 否定系
    • 演算を使う
      • age + 10 とかの時に、ageにindex貼っても効果がない

indexのデメリット

  • 追加、更新、削除が遅くなる可能性がある

まとめ

ざっくりとした雰囲気としては、開発をする上でこのカラムよくでてくるなって物に貼るといいのではないかなと。
indexを貼っても使ってくれなければ意味はない。
ステージングなどで実行計画は確認しておいた方がいい。

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?