-
Notifications
You must be signed in to change notification settings - Fork 45
Create index on issue_comments(user) and other foreign keys #35
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
Labels
enhancement
New feature or request
Comments
It sped up this query a lot - 2.5s down to 300ms: select
repos.full_name,
json_object(
'href', 'https://github.com/' || repos.full_name || '/issues/' || issues.number,
'label', '#' || issues.number
) as issue,
issues.title,
users.login,
users.id,
issues.state,
issues.locked,
issues.assignee,
issues.milestone,
issues.comments,
issues.created_at,
issues.updated_at,
issues.closed_at,
issues.author_association,
issues.pull_request,
issues.repo,
issues.type
from
issues
join repos on repos.id = issues.repo
join users on issues.user = users.id
where
issues.state = 'open'
and issues.user not in (9599, 27856297)
and not exists (
select
id
from
issue_comments
where
issue_comments.user = 9599
and issues.id = issue_comments.issue
)
order by
issues.updated_at desc; |
This sped that query up even more - down to 4ms. create index issue_comments_issue on issue_comments(issue); |
Easiest option: use |
simonw
added a commit
that referenced
this issue
May 2, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm sure there are other user columns that could benefit from an index.
The text was updated successfully, but these errors were encountered: