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 5 years have passed since last update.

インデックスの機能のメリット・デメリット(メモ書き)

Posted at

1.インデックスの機能のメリット

インデックスとは、データベースの機能の一つであり、テーブル内のデータ検索を高速化する機能を有する。そのため、インデックスを特定のテーブルのカラムに設定すると、そのカラムで検索をした時の検索速度が向上する。

2.インデックスの機能のデメリット

データ検索を高速化することで、データを保存・更新する速度が遅くなったり、データベースの容量を使ってしまうこと。

3.Railsにおけるインデックスの追加方法

マイグレーションファイルを新たに作成し、編集して特定のテーブルのカラムにインデックスを貼る。
インデックスを設定することを、「インデックスを貼る」と表現することがある。

$ rails g migration AddIndexToテーブル名

例)userテーブルにインデックスを追加したい場合

$ rails g migration AddIndexToUsers
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?