I ran a SQL query using the dataclips feature on Heroku. It works great – the results I get are in the correct order, because part of my clause specifies “ORDER BY …”.
I just pulled a copy of my database from Heroku. I then run ActiveRecord::Base.connection.execute “”
The data I get is correct, but the PGResult object has the data ordered in a completely random way — i.e. my “order by” clause is totally ignored.
I am wondering why that is happening and if there is anyway to prevent that.
We are now using the same version of Postgres as Heroku and we get the same dataset. It is, however, not correctly ordered still. The order by clause is still not working properly so we are just forcing a sort using rails (since we limit the result by 10, its not a lot of work for Rails).
I’m posting this because no one seems to have a good answer and we haven’t found anything that works either. Might as well let other folks know that for some reason, there seems to be an issue. Going to dig around a bit and potentially report a bug to postgresql folks.