[ ] I have checked my code with black, pylint, and mypy, or ./bw-dev formatters
Tests
[x] My changes do not need new tests
[ ] All tests I have added are passing
[ ] I have written tests but need help to make them pass
[ ] I have not written tests and need help to write them
What type of Pull Request is this?
[x] Bug Fix
[ ] Enhancement
[ ] Plumbing / Internals / Dependencies
[ ] Refactor
Does this PR change settings or dependencies, or break something?
[ ] This PR changes or adds default settings, configuration, or .env values
[ ] This PR changes or adds dependencies
[ ] This PR introduces other breaking changes
Details of breaking or configuration changes (if any of above checked)
Description
This definitely needs to be tested on a large DB but I believe it may fix the timeouts b.s. gets when running user exports.
Instead of a gigantic single DB query with heaps of joins, we instead just do a series of simple queries and then use union() to pull them into a de-duped queryset.
If I understand the results from explain() correctly, this is a massive reduction in DB work:
Are you finished?
Linters
black
,pylint
, andmypy
, or./bw-dev formatters
Tests
What type of Pull Request is this?
Does this PR change settings or dependencies, or break something?
Details of breaking or configuration changes (if any of above checked)
Description
This definitely needs to be tested on a large DB but I believe it may fix the timeouts b.s. gets when running user exports.
Instead of a gigantic single DB query with heaps of joins, we instead just do a series of simple queries and then use
union()
to pull them into a de-duped queryset.If I understand the results from
explain()
correctly, this is a massive reduction in DB work:Unique (cost=195899.15..198201.71 rows=11808 width=19220)
vs
Unique (cost=150.28..153.44 rows=16 width=19220)
Documentation