Skip to content

Instantly share code, notes, and snippets.

@sheldonh
Created August 12, 2009 08:07
Show Gist options
  • Save sheldonh/166385 to your computer and use it in GitHub Desktop.
Save sheldonh/166385 to your computer and use it in GitHub Desktop.
Aggregate.transaction do
write_count = 0
HourlyAggregate.connection.create_savepoint
Aggregate.find(...).each do |aggregate|
...
write_count += 1 # Only if you actually write
if write_count % 1000 == 0
HourlyAggregate.connection.release_savepoint
HourlyAggregate.connection.create_savepoint
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment