-
Notifications
You must be signed in to change notification settings - Fork 711
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
GUACAMOLE-1573: Slow selection of users on scale on Postgres #711
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format your commit message to include the JIRA issue (see established git history).
Also, from the corresponding issue in JIRA:
This solution work faster in all of the real scenarios. It can be slower only in case of selecting all of users.
This concerns me, as retrieving all users is definitely a real scenario. What happens when you do attempt to retrieve all users? If this results in N unique subqueries, rather than being turned into something efficient by the PostgreSQL server, we shouldn't do things this way.
What does PostgreSQL say for this query vs. the previous for EXPLAIN
?
Fixed commit message. Currently requests accepts list of users, which usually means that number of passed user names is considered as small. Here is the plan for selecting all users with left join + group by + max
And here is the plan for nested query
And there is the example on selecting 10 users:
Nested join
As you can see cost is bigger in case of left join in both of cases |
While I generally lean toward using The only situation where I think this may end up being sub-optimal is if, for some reason, the data in the |
Replaced left join and MAX(start_date) with selecting last record in history by start_date