Skip to content

Optimize the repos API query #5451

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

Merged
merged 1 commit into from
Mar 18, 2019
Merged

Conversation

davidfischer
Copy link
Contributor

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 a team March 13, 2019 17:34
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍

@webknjaz
Copy link
Contributor

Hi, when do you expect to deploy this?

@ericholscher
Copy link
Member

Should be deployed early this week.

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

Successfully merging this pull request may close these issues.

4 participants