I would consider adding an index to your database when using uniqueness constraints. An index significantly speeds up querying by a column by keeping everything sorted (in this case the `name` column). When checking for uniqueness without an index, Rails has to check every row in the table to see if the name has been used. If the column is sorted with an index, it can quickly find the value to see if it has been used.

You can add an index in a migration:

```ruby
def change
  add_index :ruby_gems, :name, unique: true
end
```