Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lexcao
Copy link
Contributor

@lexcao lexcao commented Jun 20, 2022

Background

From this issue #12523 background.
I found that the PR #8415 fixes the slow query on deleteExpiredClientSessions.

Features

This PR fixes another 2 slow queries on deleteClientSessionsByRealm and deleteClientSessionsByUser when using mysql and mariadb by converting sub-query to join.

I test in my local and the SQL runs normally.

2022-06-21 01:42:03,183 DEBUG [org.hibernate.SQL] (vert.x-worker-thread-0) delete c from OFFLINE_CLIENT_SESSION c join OFFLINE_USER_SESSION u where c.USER_SESSION_ID = u.USER_SESSION_ID and u.USER_ID = ?

2022-06-21 01:42:22,943 DEBUG [org.hibernate.SQL] (vert.x-worker-thread-0) delete c from OFFLINE_CLIENT_SESSION c join OFFLINE_USER_SESSION u where c.USER_SESSION_ID = u.USER_SESSION_ID and u.REALM_ID = ?

…essionsByUser` when using mysql and mariadb by converting sub-query to join
@sguilhen sguilhen added area/storage Indicates an issue that touches storage (change in data layout or data manipulation) kind/performance labels Oct 24, 2022
@sguilhen sguilhen requested a review from vramik October 24, 2022 17:48
Copy link
Contributor

@sguilhen sguilhen left a comment

Choose a reason for hiding this comment

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

Thanks @lexcao , it looks good to me. I'll ask @vramik for his review as well since he was involved in the review of #8415 which is related to this.

@vramik
Copy link
Contributor

vramik commented Oct 25, 2022

LGTM

@sschu
Copy link
Contributor

sschu commented Oct 25, 2022

Do we know this will not make the other databases slower? Maybe there was a reason why it was a subquery?

@vramik
Copy link
Contributor

vramik commented Oct 25, 2022

Do we know this will not make the other databases slower? Maybe there was a reason why it was a subquery?

By default the query remains the same: https://github.com/keycloak/keycloak/pull/12611/files#diff-14cc500714de7a7b3d908dbdaf9ddcb7abcf77686777b9daa0a290c6c78579d3R12 ... it's replaced only for mysql and mariadb

Copy link
Contributor

@hmlnarik hmlnarik left a comment

Choose a reason for hiding this comment

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

Approving per @sguilhen 's and @vramik 's reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Indicates an issue that touches storage (change in data layout or data manipulation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants