{"action":"created","comment":{"url":"https://api.github.com/repos/houndci/hound/pulls/comments/63256297","id":63256297,"diff_hunk":"@@ -0,0 +1,5 @@\n+class AddIndexForBuildsPullRequestNumberAndCommitSha < ActiveRecord::Migration\n+  def change\n+    add_index :builds, [:pull_request_number, :commit_sha]","path":"db/migrate/20160513205551_add_index_for_builds_pull_request_number_and_commit_sha.rb","position":3,"original_position":3,"commit_id":"fc4a92ddf10de76a2a805420a6bb84fdeb501f3e","original_commit_id":"fc4a92ddf10de76a2a805420a6bb84fdeb501f3e","user":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"body":"I wonder if it makes sense to have `commit_sha` first in the index, so a query searching for just that value can take advantage of the index. That seems way more likely than search by just `pull_request_number`.","created_at":"2016-05-13T21:52:11Z","updated_at":"2016-05-13T21:52:11Z","html_url":"https://github.com/houndci/hound/pull/1130#discussion_r63256297","pull_request_url":"https://api.github.com/repos/houndci/hound/pulls/1130","_links":{"self":{"href":"https://api.github.com/repos/houndci/hound/pulls/comments/63256297"},"html":{"href":"https://github.com/houndci/hound/pull/1130#discussion_r63256297"},"pull_request":{"href":"https://api.github.com/repos/houndci/hound/pulls/1130"}}},"pull_request":{"url":"https://api.github.com/repos/houndci/hound/pulls/1130","id":70062701,"html_url":"https://github.com/houndci/hound/pull/1130","diff_url":"https://github.com/houndci/hound/pull/1130.diff","patch_url":"https://github.com/houndci/hound/pull/1130.patch","issue_url":"https://api.github.com/repos/houndci/hound/issues/1130","number":1130,"state":"open","locked":false,"title":"Add index for builds pr number and sha","user":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"body":"When completing a file review job, we find the associated build record\r\nby pull request number and commit sha. With about 1.6 million records\r\nin the table, this query is averaging 1820ms to execute.\r\n\r\nThis adds an index on the pull_request_number/commit_sha pair to improve\r\nthe performance of that query.","created_at":"2016-05-13T21:44:13Z","updated_at":"2016-05-13T21:52:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e8a715e8d4f7e94cb4cdabf3b5ccada7306ea54","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/houndci/hound/pulls/1130/commits","review_comments_url":"https://api.github.com/repos/houndci/hound/pulls/1130/comments","review_comment_url":"https://api.github.com/repos/houndci/hound/pulls/comments{/number}","comments_url":"https://api.github.com/repos/houndci/hound/issues/1130/comments","statuses_url":"https://api.github.com/repos/houndci/hound/statuses/fc4a92ddf10de76a2a805420a6bb84fdeb501f3e","head":{"label":"houndci:ct-build-index","ref":"ct-build-index","sha":"fc4a92ddf10de76a2a805420a6bb84fdeb501f3e","user":{"login":"houndci","id":17184073,"avatar_url":"https://avatars.githubusercontent.com/u/17184073?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"Organization","site_admin":false},"repo":{"id":7411076,"name":"hound","full_name":"houndci/hound","owner":{"login":"houndci","id":17184073,"avatar_url":"https://avatars.githubusercontent.com/u/17184073?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/houndci/hound","description":"Automated review for code style","fork":false,"url":"https://api.github.com/repos/houndci/hound","forks_url":"https://api.github.com/repos/houndci/hound/forks","keys_url":"https://api.github.com/repos/houndci/hound/keys{/key_id}","collaborators_url":"https://api.github.com/repos/houndci/hound/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/houndci/hound/teams","hooks_url":"https://api.github.com/repos/houndci/hound/hooks","issue_events_url":"https://api.github.com/repos/houndci/hound/issues/events{/number}","events_url":"https://api.github.com/repos/houndci/hound/events","assignees_url":"https://api.github.com/repos/houndci/hound/assignees{/user}","branches_url":"https://api.github.com/repos/houndci/hound/branches{/branch}","tags_url":"https://api.github.com/repos/houndci/hound/tags","blobs_url":"https://api.github.com/repos/houndci/hound/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/houndci/hound/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/houndci/hound/git/refs{/sha}","trees_url":"https://api.github.com/repos/houndci/hound/git/trees{/sha}","statuses_url":"https://api.github.com/repos/houndci/hound/statuses/{sha}","languages_url":"https://api.github.com/repos/houndci/hound/languages","stargazers_url":"https://api.github.com/repos/houndci/hound/stargazers","contributors_url":"https://api.github.com/repos/houndci/hound/contributors","subscribers_url":"https://api.github.com/repos/houndci/hound/subscribers","subscription_url":"https://api.github.com/repos/houndci/hound/subscription","commits_url":"https://api.github.com/repos/houndci/hound/commits{/sha}","git_commits_url":"https://api.github.com/repos/houndci/hound/git/commits{/sha}","comments_url":"https://api.github.com/repos/houndci/hound/comments{/number}","issue_comment_url":"https://api.github.com/repos/houndci/hound/issues/comments{/number}","contents_url":"https://api.github.com/repos/houndci/hound/contents/{+path}","compare_url":"https://api.github.com/repos/houndci/hound/compare/{base}...{head}","merges_url":"https://api.github.com/repos/houndci/hound/merges","archive_url":"https://api.github.com/repos/houndci/hound/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/houndci/hound/downloads","issues_url":"https://api.github.com/repos/houndci/hound/issues{/number}","pulls_url":"https://api.github.com/repos/houndci/hound/pulls{/number}","milestones_url":"https://api.github.com/repos/houndci/hound/milestones{/number}","notifications_url":"https://api.github.com/repos/houndci/hound/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/houndci/hound/labels{/name}","releases_url":"https://api.github.com/repos/houndci/hound/releases{/id}","deployments_url":"https://api.github.com/repos/houndci/hound/deployments","created_at":"2013-01-02T18:12:40Z","updated_at":"2016-05-13T04:03:22Z","pushed_at":"2016-05-13T21:44:14Z","git_url":"git://github.com/houndci/hound.git","ssh_url":"git@github.com:houndci/hound.git","clone_url":"https://github.com/houndci/hound.git","svn_url":"https://github.com/houndci/hound","homepage":"https://houndci.com","size":6462,"stargazers_count":1256,"watchers_count":1256,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":273,"mirror_url":null,"open_issues_count":37,"forks":273,"open_issues":37,"watchers":1256,"default_branch":"master"}},"base":{"label":"houndci:master","ref":"master","sha":"a46b641696d8861663cf7381f06ca7a9d8d4e9db","user":{"login":"houndci","id":17184073,"avatar_url":"https://avatars.githubusercontent.com/u/17184073?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"Organization","site_admin":false},"repo":{"id":7411076,"name":"hound","full_name":"houndci/hound","owner":{"login":"houndci","id":17184073,"avatar_url":"https://avatars.githubusercontent.com/u/17184073?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/houndci/hound","description":"Automated review for code style","fork":false,"url":"https://api.github.com/repos/houndci/hound","forks_url":"https://api.github.com/repos/houndci/hound/forks","keys_url":"https://api.github.com/repos/houndci/hound/keys{/key_id}","collaborators_url":"https://api.github.com/repos/houndci/hound/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/houndci/hound/teams","hooks_url":"https://api.github.com/repos/houndci/hound/hooks","issue_events_url":"https://api.github.com/repos/houndci/hound/issues/events{/number}","events_url":"https://api.github.com/repos/houndci/hound/events","assignees_url":"https://api.github.com/repos/houndci/hound/assignees{/user}","branches_url":"https://api.github.com/repos/houndci/hound/branches{/branch}","tags_url":"https://api.github.com/repos/houndci/hound/tags","blobs_url":"https://api.github.com/repos/houndci/hound/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/houndci/hound/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/houndci/hound/git/refs{/sha}","trees_url":"https://api.github.com/repos/houndci/hound/git/trees{/sha}","statuses_url":"https://api.github.com/repos/houndci/hound/statuses/{sha}","languages_url":"https://api.github.com/repos/houndci/hound/languages","stargazers_url":"https://api.github.com/repos/houndci/hound/stargazers","contributors_url":"https://api.github.com/repos/houndci/hound/contributors","subscribers_url":"https://api.github.com/repos/houndci/hound/subscribers","subscription_url":"https://api.github.com/repos/houndci/hound/subscription","commits_url":"https://api.github.com/repos/houndci/hound/commits{/sha}","git_commits_url":"https://api.github.com/repos/houndci/hound/git/commits{/sha}","comments_url":"https://api.github.com/repos/houndci/hound/comments{/number}","issue_comment_url":"https://api.github.com/repos/houndci/hound/issues/comments{/number}","contents_url":"https://api.github.com/repos/houndci/hound/contents/{+path}","compare_url":"https://api.github.com/repos/houndci/hound/compare/{base}...{head}","merges_url":"https://api.github.com/repos/houndci/hound/merges","archive_url":"https://api.github.com/repos/houndci/hound/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/houndci/hound/downloads","issues_url":"https://api.github.com/repos/houndci/hound/issues{/number}","pulls_url":"https://api.github.com/repos/houndci/hound/pulls{/number}","milestones_url":"https://api.github.com/repos/houndci/hound/milestones{/number}","notifications_url":"https://api.github.com/repos/houndci/hound/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/houndci/hound/labels{/name}","releases_url":"https://api.github.com/repos/houndci/hound/releases{/id}","deployments_url":"https://api.github.com/repos/houndci/hound/deployments","created_at":"2013-01-02T18:12:40Z","updated_at":"2016-05-13T04:03:22Z","pushed_at":"2016-05-13T21:44:14Z","git_url":"git://github.com/houndci/hound.git","ssh_url":"git@github.com:houndci/hound.git","clone_url":"https://github.com/houndci/hound.git","svn_url":"https://github.com/houndci/hound","homepage":"https://houndci.com","size":6462,"stargazers_count":1256,"watchers_count":1256,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":273,"mirror_url":null,"open_issues_count":37,"forks":273,"open_issues":37,"watchers":1256,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/houndci/hound/pulls/1130"},"html":{"href":"https://github.com/houndci/hound/pull/1130"},"issue":{"href":"https://api.github.com/repos/houndci/hound/issues/1130"},"comments":{"href":"https://api.github.com/repos/houndci/hound/issues/1130/comments"},"review_comments":{"href":"https://api.github.com/repos/houndci/hound/pulls/1130/comments"},"review_comment":{"href":"https://api.github.com/repos/houndci/hound/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/houndci/hound/pulls/1130/commits"},"statuses":{"href":"https://api.github.com/repos/houndci/hound/statuses/fc4a92ddf10de76a2a805420a6bb84fdeb501f3e"}}}}