Free result after using ActiveRecord::Base.connection.execute
Just a quick warning: when you use ActiveRecord::Base.connection.execute
you get a Mysql::Result instance, this is a very thin wrapper around the actual result returned from libmysqlclient. This means you have to free the memory of the result table, failing to do so will result in erratic query times because somewhere a garbage collector will do it for you.
When you want to select a number of entire rows, you can use the already safe select_rows
.