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

Reduce queries while generating orders #158

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

coreymckrill
Copy link
Contributor

@coreymckrill coreymckrill commented Jan 4, 2025

Changes proposed in this Pull Request:

This reduces the number of queries that run during order generation by storing lists of customer and product IDs that are used in orders in a runtime cache, rather than making new queries for those IDs every time an order is generated. The runtime cache does get refreshed every 100 orders, so that a greater variety of customers and products will be used during large batches.

More crucially, this seems to mitigate the memory leak described in #152. With these changes, I was able to run the command mentioned in the issue to generate 50k orders and never encountered an out of memory error. (It still took forever, I just let it run overnight 😄)

Note that this also changes the behavior of the Orders generator so that it no longer generates new customer accounts. It will only use existing accounts or generate data for "guest" orders. Customers can be generated separately using the Customers generator before running the Orders generator.

Builds off of #119
Towards #152

How to test the changes in this Pull Request:

  1. TBD

Changelog entry

This makes a significant reduction in queries by storing lists of
customer and product IDs in a runtime cache, rather than making new
queries for those IDs every time an order is generated. The runtime
cache does get refreshed every 100 orders, so that a greater variety
of customers and products will be used.
@coreymckrill coreymckrill self-assigned this Jan 4, 2025
Base automatically changed from fix/119/product-term-decouple to trunk January 10, 2025 12:30
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.

1 participant