It's about time we should fix this - right now ActiveRecord::ConnectionAdapters::MysqlAdapter has this code block:
def case_sensitive_equality_operator
"= BINARY"
end
which renders validates_uniqueness_of prohibitively slow. With 7M records, it takes 3+ seconds in our case. It really should be:
def case_sensitive_equality_operator
"="
end
That way, we benefit from MySQL's collation for case sensitivity in the index (like utf8_unicode_ci or utf8_bin), which is FAST. Or we could add :case_sensitive => nil as a new option particularly for that case.
It's a known problem for a long time actually, and patches have been around: