Just had to debug where one query that took up to 5 seconds on production came from. The query itself is following
SELECT `users`.id FROM `users` WHERE (LOWER(`users`.`email`) = BINARY 'christoph@vedanova.com' AND `users`.id <> 68752) LIMIT 1
The problem with this query is, that is it is not using an index and it cannot use an index because of the “LOWER” statement. The query was caused by the Active Record by the validates_uniqueness_of validation
validates_uniqueness_of :email, :case_sensitive => false
and is/was a long outstanding issue. Still in Rails 2.3.12 it is causing this query.
Credits go to Floorplanner.
Here is the link to the Lighthouse ticket.