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

Optimize the repos API query #5451

Merged
merged 1 commit into from Mar 18, 2019
Merged

Conversation

@davidfischer
Copy link
Contributor

@davidfischer davidfischer commented Mar 13, 2019

The goal of this PR is to speed up the https://readthedocs.org/api/v2/remote/repo/ API endpoint. Specifically this is used on the repository import page and we've seen some timeouts.

  • Adds an index to Project.repo. This is queried heavily and without an index we are looking at a full table scan. This is useful not just here but elsewhere as well.
  • There is a straight forward select_related optimization on repository organizations
  • In order to disallow importing duplicate repos, we currently do a rather inefficient fuzzy match on repositories. This query is done for each repository in the query resulting in up to 15 additional queries (each of which currently results in a full table scan). This change attempts to optimize this matching query but it isn't totally lossless:
    • The change will no longer find case insensitive matches
    • The query attempts to do a very similar fuzzy match with respect to git:// URLs or URLs ending in .git but it is not exactly the same

Fixes #5441

@davidfischer davidfischer requested a review from Mar 13, 2019
stsewd
stsewd approved these changes Mar 13, 2019
Copy link
Member

@ericholscher ericholscher left a comment

Looks good to me. 👍

@webknjaz
Copy link

@webknjaz webknjaz commented Mar 17, 2019

Hi, when do you expect to deploy this?

@ericholscher
Copy link
Member

@ericholscher ericholscher commented Mar 17, 2019

Should be deployed early this week.

@ericholscher ericholscher merged commit 5e3c099 into master Mar 18, 2019
1 check passed
@delete-merged-branch delete-merged-branch bot deleted the davidfischer/optimize-repo-queries branch Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants