Last active
August 29, 2015 13:56
-
-
Save swordray/9168494 to your computer and use it in GitHub Desktop.
ActiveRecord serialization with 1000% performance improvement by skipping instantiation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
records = ActiveRecordClass.select().where().order().paginate() | |
# before | |
records.to_json | |
# after - with 1000% performance improvement | |
records.klass.connection.execute(records.to_sql).to_a.map { |record| [records.select_values, record].transpose.to_h } }.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how would you use this for active record relations?