Created
April 15, 2021 05:56
-
-
Save Mattamorphic/796c99f05b6b2d4be625861dea7713d5 to your computer and use it in GitHub Desktop.
Compression Rails
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
Tempfile.open(["#{Rails.root}/tmp/", ".csv"]) do |f| | |
# Write the batch to a csv file (cheaper than 5000 queries) | |
f = ActiveSupport::Gzip.compress(ModelDatum.where(model_id: 2).pluck(:id, :preprocessed_data).map(&:to_csv).join) | |
puts f.size() | |
puts ActiveSupport::Gzip.decompress(f) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment