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

possible fix for #3372 - user export timeouts #3378

Merged
merged 2 commits into from
Jun 23, 2024

Conversation

hughrun
Copy link
Contributor

@hughrun hughrun commented Jun 9, 2024

Are you finished?

Linters

  • I have checked my code with black, pylint, and mypy, or ./bw-dev formatters

Tests

  • 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?

  • 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:

Unique (cost=195899.15..198201.71 rows=11808 width=19220)

vs

Unique (cost=150.28..153.44 rows=16 width=19220)

Documentation

  • New or amended documentation will be required if this PR is merged
  • I have created a matching pull request in the Documentation repository
  • I intend to create a matching pull request in the Documentation repository after this PR is merged

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)
@hughrun hughrun added the performance Things related to performance, optimization, load times, etc label Jun 9, 2024
@hughrun hughrun requested review from mouse-reeve and WesleyAC June 9, 2024 00:44
remove Q import so pylint doesn't grumble
@mouse-reeve
Copy link
Member

I tried this with the query time test system in #3380 and it when from 0.06 to 0.003 which is a huge improvement!

@mouse-reeve mouse-reeve merged commit 3236003 into bookwyrm-social:main Jun 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Things related to performance, optimization, load times, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Account export times out when trying to generate export json
2 participants