-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
accessibleRepositoryCondition makes an awful "where condition" in SQL #10457
Comments
Hi, this will hopefully be fixed by #9787, but I couldn't advance with it because there are other PRs it's depending on that are still waiting for approval. Currently xorm produces invalid code for SQLite regarding unions, unfortunately. |
We tried to keep the logic of your code as much as we could. Regarding SQLite, we've ran the test after we wrote the issue. And yes. Unions aren't working with xorm and SQLite :) |
Some of the INs could probably be coalesced without the use of Union I think. When I wrote the code the idea was readability over efficiency - as ever the way people use Gitea always exceeds expectations. If you can come up with a way of making sqlite work your fix would be useful - if only as a staging step to spur @guillep2k to finish #9787 😛 |
The real issue here, IMHO, are more the OR than the IN. |
If you move the some of the ORs into the INs so there is only one or very few INs that will likely be much quicker. |
For example the ("repository".owner_id NOT IN (SELECT id FROM "user" WHERE type=1) OR "repository".owner_id NOT IN (SELECT id FROM "user" WHERE visibility IN (2))) Could be simplified to: ("repository".owner_id NOT IN (SELECT id FROM "user" WHERE type=1 OR visibility IN (2))) And so on... |
The assumption was that the inefficiency was unlikely to bite because who would have 200k repositories... |
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions. |
[x]
):Description
Hi we have a user with more than 200k repo and more than 600k action on them.
We cannot connect on the website anymore with this user
We found out that the issue was from a request that make the front end time out.
We ve been searching in the code. We ve found the request
The main issue here (at least in postgres) is the over use of OR and the use of IN with some sub queries.
To fix it we ve used some subqueries with UNION
For info we let the first query run for more than 20min without a response.
Our new query is less than 5 seconds.
We haven't try with all the different type of databases. Do you think there will be issues with other DB?
Do you see any other better/good solution?
Should we make a pull request?
Thanks
...
Screenshots
I am pretty sure you know what a 504 is :)
The text was updated successfully, but these errors were encountered: