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

Slow query when hydra_oauth2_consent_request growth #1987

Closed
purmac opened this issue Aug 12, 2020 · 2 comments
Closed

Slow query when hydra_oauth2_consent_request growth #1987

purmac opened this issue Aug 12, 2020 · 2 comments

Comments

@purmac
Copy link

purmac commented Aug 12, 2020

Hydra Version: v1.0.0+oryOS.12
Database: CockroachDB 19.2

Hi Team,

We've observed the slow consent sql query similar to the issue #1454
When running

SELECT h.*
FROM hydra_oauth2_consent_request_handled AS h
         JOIN hydra_oauth2_consent_request AS r ON (h.challenge = r.challenge)
WHERE (((r.subject = $1 ) AND (r.client_id = $2)) AND (r.skip = true))
  AND ((h.error = '{}') AND (h.remember = true))
ORDER BY h.requested_at DESC limit 1;

The query time growth linearly with the number of records for a subject in hydra_oauth2_consent_request

For a subject that has 1040 records in hydra_oauth2_consent_request. It take 14ms to complete the query
For a subject that has 305683 records in hydra_oauth2_consent_request. It takes 23 sec to complete.

Purging the hydra_oauth2_consent_request table might mitigate the issue. However, but there is no API or shell scripts to do the cleanup. As discussed in #1574

I'm not sure Ory team is aware of this behavior. There might be a SQL optimization can be done in for this problem. Thanks.

@purmac purmac changed the title Slow query when hydra_oauth2_consent_request Slow query when hydra_oauth2_consent_request growth Aug 12, 2020
@aeneasr
Copy link
Member

aeneasr commented Aug 12, 2020

Version 1.0 is over a year old, we are now at 1.6 and the addressed issue has long been reported and resolved :) Consider signing up to the newsletter and stay informed about updates: https://ory.us10.list-manage.com/subscribe?u=ffb1a878e4ec6c0ed312a3480&id=f605a41b53&MERGE0=

@purmac
Copy link
Author

purmac commented Aug 12, 2020

Thanks @aeneasr

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

No branches or pull requests

2 participants