charlotte-ruby/impressionist — pull request #24 by lacco (2012-01-19 20:36:48+00:00)
Title: speedup unique impressions

When using the :unique option, then a ```impressions.count == 0```is used to validate uniqueness. This requires a full table scan every time (without appropriate indexes):

```SELECT COUNT(*) FROM `impressions````

Using ```!impressions.exists?``` results in a much more efficient query (but even requires a full table scan when there is no existing impression):

```SELECT 1 FROM `impressions` LIMIT 1```