Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Fixes #68 -- improve performance of data migration #69

Merged
merged 2 commits into from Oct 27, 2023

Conversation

sergei-maertens
Copy link
Contributor

Tested against a 13GB SQL dump of the email table (~23K records), within a cgroup with 300M memory limit. The migration completed in just under 60s.

  • Use iterator to avoid loading entire table in memory (for the queryset cache)
  • Defer the message content, as it may contain attachments causing excessive memory usage - it is not used in the migration anyway.
  • Replace loop over log table with 3 separate SQL update queries

Tested against a 13GB SQL dump of the email table (~23K records),
within a cgroup with 300M memory limit. The migration completed
in just under 60s.

* Use iterator to avoid loading entire table in memory (for the queryset cache)
* Defer the message content, as it may contain attachments causing excessive
  memory usage - it is not used in the migration anyway.
* Replace loop over log table with 3 separate SQL update queries
@coveralls
Copy link

coveralls commented Oct 5, 2023

Coverage Status

coverage: 77.209%. remained the same when pulling c17ad0c on maykinmedia:issue/68-performance-data-migration into 30d37c5 on APSL:master.

@joeribekker
Copy link

joeribekker commented Oct 5, 2023

@sergei-maertens can confirm that this works. Migration took about a minute. Thanks!

@sastred
Copy link
Member

sastred commented Oct 6, 2023

Nice! Feel free to add the no-op backwards migrations.

Discussed in the context of APSL#68 - the reverse data migration is not
implemented (deliberately), but that shouldn't prevent people from
rolling back their migrations in dev-environments and while
debugging/diagnosing issues, for example.
@sergei-maertens
Copy link
Contributor Author

Nice! Feel free to add the no-op backwards migrations.

I've added it!

@sastred sastred self-assigned this Oct 17, 2023
@sastred sastred merged commit b9523a8 into APSL:master Oct 27, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants