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

Optimize get_audience #2785

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

WesleyAC
Copy link
Member

@WesleyAC WesleyAC commented Apr 6, 2023

See #2720 (as well as the commit messages) for details. I haven't done detailed performance analysis on these queries (in part because doing so well would require data from #2779 in prod), but I think it's highly likely that these changes will allow Postgres to use the indices it has, and reduce these queries from ~8 seconds to hundreds of milliseconds at most, given that's what I saw for the narrower case of this that I analyzed before.

I don't have a super high level of confidence in this code, but it is to the best of my knowledge correct. This is just a fiddly part of the codebase, so I want to be careful.

WesleyAC added 2 commits April 7, 2023 10:37
I suspect this will make some future work simpler.
This avoids filtering for the user that made the post in the same query
as we use for other things, which should allow for better use of indices
in all cases. Previously, bookwyrm-social#2723 did some work on this that only worked
for some cases in HomeStream, but this code should work for all cases.

Related: bookwyrm-social#2720
@WesleyAC WesleyAC force-pushed the optimize-get-audience branch from 55f02d8 to 07b50a1 Compare April 7, 2023 14:38
@WesleyAC
Copy link
Member Author

WesleyAC commented Apr 7, 2023

@mouse-reeve conflict resolved :)

@mouse-reeve mouse-reeve merged commit 7272ca2 into bookwyrm-social:main Apr 7, 2023
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.

2 participants