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

union users and groups for better perf #768

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

qeternity
Copy link
Contributor

@qeternity qeternity commented Dec 11, 2021

In our benchmarks, the current get_users_with_perms shortcut is improved by unioning when using the with_group_users flag. For our typical usecases, this drops query time by ca. 60% (5ms -> 2ms) with reasonably large production tables running on postgres, and cut the number of queries in half (as we do not force execution of the group id query, which I suspect was done for performance reasons anyway).

Of course, I am sure that other database query planners may perform differently, but it is likely that the union approach still comes out ahead sufficiently by avoiding an outer join on potentially large tables.

Copy link
Member

@ad-m ad-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, but I haven't run any benchmarks.

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

2 participants