I have a query in my dev environment that typically takes about 1.7 ms to run on the dev mySQL database. When bumped up to Heroku and PostgreSQL, the same query on the same data set is taking about 1.2 seconds!
SELECT distinct user_id, score, quality
FROM `reports`
WHERE (datetime_utc >= '2012-01-13 14:00:00' AND
datetime_utc <= '2012-01-14 14:00:00')
ORDER BY score DESC, quality DESC LIMIT 20
I created a compound index on score and quality which helped with the SQL version, but the query running on PostgreSQL is still very, very slow. My first instinct is to check that the index is actually in place on the Heroku side, but i'm not sure quite how to do that - in any case, i have a feeling it's more to do with the fact that mySQL and PostgreSQL don't do things quite the same way.
Any insights or pointers would be hugely appreciated!
datetime_utc?