0

I have a users table and there is an index on that table:

add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree

The index type is btree and email is a unique field.
Is it worth having this index or is it better to just remove it?

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
Bri6ko
  • 1,858
  • 1
  • 18
  • 29

2 Answers2

1

I would remove it first and then use lol_dba db:find_indexes from lol_dba to see if it recommends adding the index.

Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
1

If the column is defined UNIQUE, it is indexed with a unique btree index automatically anyway, because that's how Postgres implements a UNIQUE constraint.

An additional index would be redundant, dead freight. Delete it.

Details:

Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228