{"action":"closed","number":192,"pull_request":{"url":"https://api.github.com/repos/genome/ptero-workflow/pulls/192","id":44294693,"html_url":"https://github.com/genome/ptero-workflow/pull/192","diff_url":"https://github.com/genome/ptero-workflow/pull/192.diff","patch_url":"https://github.com/genome/ptero-workflow/pull/192.patch","issue_url":"https://api.github.com/repos/genome/ptero-workflow/issues/192","number":192,"state":"closed","locked":false,"title":"Add indexes to improve performance","user":{"login":"davidlmorton","id":650482,"avatar_url":"https://avatars.githubusercontent.com/u/650482?v=3","gravatar_id":"","url":"https://api.github.com/users/davidlmorton","html_url":"https://github.com/davidlmorton","followers_url":"https://api.github.com/users/davidlmorton/followers","following_url":"https://api.github.com/users/davidlmorton/following{/other_user}","gists_url":"https://api.github.com/users/davidlmorton/gists{/gist_id}","starred_url":"https://api.github.com/users/davidlmorton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidlmorton/subscriptions","organizations_url":"https://api.github.com/users/davidlmorton/orgs","repos_url":"https://api.github.com/users/davidlmorton/repos","events_url":"https://api.github.com/users/davidlmorton/events{/privacy}","received_events_url":"https://api.github.com/users/davidlmorton/received_events","type":"User","site_admin":false},"body":"Using the postgres contrib 'pg_stat_statements' module, I was able to\r\ndetermine what the cause of our performance degradation was:\r\n\r\n```\r\nptero_workflow=# SELECT query, total_time, calls, total_time/calls as\r\ntime_per_call, rows/calls as rows_per_call FROM pg_stat_statements\r\nORDER BY time_per_call;\r\n```\r\n\r\n```\r\nquery         | SELECT execution_status_history.id AS\r\nexecution_status_history_id, execution_status_history.execution_id AS\r\nexecution_status_history_execution_id, execution_statu\r\ns_history.timestamp AS execution_status_history_timestamp,\r\nexecution_status_history.status AS execution_status_history_status\r\n              | FROM execution_status_history\r\n              | WHERE ? = execution_status_history.execution_id ORDER\r\nBY execution_status_history.timestamp\r\ntotal_time    | 5094.504\r\ncalls         | 309\r\ntime_per_call | 16.487067961165\r\nrows_per_call | 3\r\n```\r\n\r\nThen using the EXPLAIN command, I was able to spot the missing index:\r\n\r\n```\r\nptero_workflow=# EXPLAIN SELECT execution_status_history.id AS\r\nexecution_status_history_id, execution_status_history.execution_id AS\r\nexecution_status_history_execution_id, execution_status_history.timestamp AS\r\nexecution_status_history_timestamp,\r\nexecution_status_history.status AS execution_status_history_status FROM\r\nexecution_status_history WHERE 1 = execution_status_history.execution_id\r\nORDER BY\r\nexecution_status_history.timestamp;\r\n```\r\n\r\n```\r\n-[ RECORD 1 ]----------------------------------------------\r\nQUERY PLAN | Sort  (cost=4583.27..4583.28 rows=4 width=23)\r\n-[ RECORD 2 ]----------------------------------------------\r\nQUERY PLAN |   Sort Key: \"timestamp\"\r\n-[ RECORD 3 ]----------------------------------------------\r\nQUERY PLAN |   ->  Seq Scan on execution_status_history\r\n(cost=0.00..4583.23 rows=4 width=23)\r\n-[ RECORD 4 ]----------------------------------------------\r\nQUERY PLAN |         Filter: (5 = execution_id)\r\n```\r\n\r\nAfter adding these indexes, which were added based on other similar\r\nexplain statements, the performance degradation was no longer\r\nobservable","created_at":"2015-09-06T03:30:08Z","updated_at":"2015-09-08T14:41:33Z","closed_at":"2015-09-08T14:41:32Z","merged_at":"2015-09-08T14:41:32Z","merge_commit_sha":"70afabf70011432a3970d8944ff41bfb6987ae64","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/genome/ptero-workflow/pulls/192/commits","review_comments_url":"https://api.github.com/repos/genome/ptero-workflow/pulls/192/comments","review_comment_url":"https://api.github.com/repos/genome/ptero-workflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/genome/ptero-workflow/issues/192/comments","statuses_url":"https://api.github.com/repos/genome/ptero-workflow/statuses/809f2665de868956ffa1ab25a4e41a2a531f38a3","head":{"label":"genome:fix_performance_degradation","ref":"fix_performance_degradation","sha":"809f2665de868956ffa1ab25a4e41a2a531f38a3","user":{"login":"genome","id":318108,"avatar_url":"https://avatars.githubusercontent.com/u/318108?v=3","gravatar_id":"","url":"https://api.github.com/users/genome","html_url":"https://github.com/genome","followers_url":"https://api.github.com/users/genome/followers","following_url":"https://api.github.com/users/genome/following{/other_user}","gists_url":"https://api.github.com/users/genome/gists{/gist_id}","starred_url":"https://api.github.com/users/genome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genome/subscriptions","organizations_url":"https://api.github.com/users/genome/orgs","repos_url":"https://api.github.com/users/genome/repos","events_url":"https://api.github.com/users/genome/events{/privacy}","received_events_url":"https://api.github.com/users/genome/received_events","type":"Organization","site_admin":false},"repo":{"id":18342541,"name":"ptero-workflow","full_name":"genome/ptero-workflow","owner":{"login":"genome","id":318108,"avatar_url":"https://avatars.githubusercontent.com/u/318108?v=3","gravatar_id":"","url":"https://api.github.com/users/genome","html_url":"https://github.com/genome","followers_url":"https://api.github.com/users/genome/followers","following_url":"https://api.github.com/users/genome/following{/other_user}","gists_url":"https://api.github.com/users/genome/gists{/gist_id}","starred_url":"https://api.github.com/users/genome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genome/subscriptions","organizations_url":"https://api.github.com/users/genome/orgs","repos_url":"https://api.github.com/users/genome/repos","events_url":"https://api.github.com/users/genome/events{/privacy}","received_events_url":"https://api.github.com/users/genome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/genome/ptero-workflow","description":"Client-facing API for the PTero system","fork":false,"url":"https://api.github.com/repos/genome/ptero-workflow","forks_url":"https://api.github.com/repos/genome/ptero-workflow/forks","keys_url":"https://api.github.com/repos/genome/ptero-workflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/genome/ptero-workflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/genome/ptero-workflow/teams","hooks_url":"https://api.github.com/repos/genome/ptero-workflow/hooks","issue_events_url":"https://api.github.com/repos/genome/ptero-workflow/issues/events{/number}","events_url":"https://api.github.com/repos/genome/ptero-workflow/events","assignees_url":"https://api.github.com/repos/genome/ptero-workflow/assignees{/user}","branches_url":"https://api.github.com/repos/genome/ptero-workflow/branches{/branch}","tags_url":"https://api.github.com/repos/genome/ptero-workflow/tags","blobs_url":"https://api.github.com/repos/genome/ptero-workflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/genome/ptero-workflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/genome/ptero-workflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/genome/ptero-workflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/genome/ptero-workflow/statuses/{sha}","languages_url":"https://api.github.com/repos/genome/ptero-workflow/languages","stargazers_url":"https://api.github.com/repos/genome/ptero-workflow/stargazers","contributors_url":"https://api.github.com/repos/genome/ptero-workflow/contributors","subscribers_url":"https://api.github.com/repos/genome/ptero-workflow/subscribers","subscription_url":"https://api.github.com/repos/genome/ptero-workflow/subscription","commits_url":"https://api.github.com/repos/genome/ptero-workflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/genome/ptero-workflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/genome/ptero-workflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/genome/ptero-workflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/genome/ptero-workflow/contents/{+path}","compare_url":"https://api.github.com/repos/genome/ptero-workflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/genome/ptero-workflow/merges","archive_url":"https://api.github.com/repos/genome/ptero-workflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/genome/ptero-workflow/downloads","issues_url":"https://api.github.com/repos/genome/ptero-workflow/issues{/number}","pulls_url":"https://api.github.com/repos/genome/ptero-workflow/pulls{/number}","milestones_url":"https://api.github.com/repos/genome/ptero-workflow/milestones{/number}","notifications_url":"https://api.github.com/repos/genome/ptero-workflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/genome/ptero-workflow/labels{/name}","releases_url":"https://api.github.com/repos/genome/ptero-workflow/releases{/id}","created_at":"2014-04-01T19:56:33Z","updated_at":"2015-04-29T20:48:05Z","pushed_at":"2015-09-08T14:41:33Z","git_url":"git://github.com/genome/ptero-workflow.git","ssh_url":"git@github.com:genome/ptero-workflow.git","clone_url":"https://github.com/genome/ptero-workflow.git","svn_url":"https://github.com/genome/ptero-workflow","homepage":"","size":1987,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":22,"forks":3,"open_issues":22,"watchers":1,"default_branch":"master"}},"base":{"label":"genome:master","ref":"master","sha":"75d53ae0ae30d2a7926ea0a128b054821d4e4e91","user":{"login":"genome","id":318108,"avatar_url":"https://avatars.githubusercontent.com/u/318108?v=3","gravatar_id":"","url":"https://api.github.com/users/genome","html_url":"https://github.com/genome","followers_url":"https://api.github.com/users/genome/followers","following_url":"https://api.github.com/users/genome/following{/other_user}","gists_url":"https://api.github.com/users/genome/gists{/gist_id}","starred_url":"https://api.github.com/users/genome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genome/subscriptions","organizations_url":"https://api.github.com/users/genome/orgs","repos_url":"https://api.github.com/users/genome/repos","events_url":"https://api.github.com/users/genome/events{/privacy}","received_events_url":"https://api.github.com/users/genome/received_events","type":"Organization","site_admin":false},"repo":{"id":18342541,"name":"ptero-workflow","full_name":"genome/ptero-workflow","owner":{"login":"genome","id":318108,"avatar_url":"https://avatars.githubusercontent.com/u/318108?v=3","gravatar_id":"","url":"https://api.github.com/users/genome","html_url":"https://github.com/genome","followers_url":"https://api.github.com/users/genome/followers","following_url":"https://api.github.com/users/genome/following{/other_user}","gists_url":"https://api.github.com/users/genome/gists{/gist_id}","starred_url":"https://api.github.com/users/genome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genome/subscriptions","organizations_url":"https://api.github.com/users/genome/orgs","repos_url":"https://api.github.com/users/genome/repos","events_url":"https://api.github.com/users/genome/events{/privacy}","received_events_url":"https://api.github.com/users/genome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/genome/ptero-workflow","description":"Client-facing API for the PTero system","fork":false,"url":"https://api.github.com/repos/genome/ptero-workflow","forks_url":"https://api.github.com/repos/genome/ptero-workflow/forks","keys_url":"https://api.github.com/repos/genome/ptero-workflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/genome/ptero-workflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/genome/ptero-workflow/teams","hooks_url":"https://api.github.com/repos/genome/ptero-workflow/hooks","issue_events_url":"https://api.github.com/repos/genome/ptero-workflow/issues/events{/number}","events_url":"https://api.github.com/repos/genome/ptero-workflow/events","assignees_url":"https://api.github.com/repos/genome/ptero-workflow/assignees{/user}","branches_url":"https://api.github.com/repos/genome/ptero-workflow/branches{/branch}","tags_url":"https://api.github.com/repos/genome/ptero-workflow/tags","blobs_url":"https://api.github.com/repos/genome/ptero-workflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/genome/ptero-workflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/genome/ptero-workflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/genome/ptero-workflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/genome/ptero-workflow/statuses/{sha}","languages_url":"https://api.github.com/repos/genome/ptero-workflow/languages","stargazers_url":"https://api.github.com/repos/genome/ptero-workflow/stargazers","contributors_url":"https://api.github.com/repos/genome/ptero-workflow/contributors","subscribers_url":"https://api.github.com/repos/genome/ptero-workflow/subscribers","subscription_url":"https://api.github.com/repos/genome/ptero-workflow/subscription","commits_url":"https://api.github.com/repos/genome/ptero-workflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/genome/ptero-workflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/genome/ptero-workflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/genome/ptero-workflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/genome/ptero-workflow/contents/{+path}","compare_url":"https://api.github.com/repos/genome/ptero-workflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/genome/ptero-workflow/merges","archive_url":"https://api.github.com/repos/genome/ptero-workflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/genome/ptero-workflow/downloads","issues_url":"https://api.github.com/repos/genome/ptero-workflow/issues{/number}","pulls_url":"https://api.github.com/repos/genome/ptero-workflow/pulls{/number}","milestones_url":"https://api.github.com/repos/genome/ptero-workflow/milestones{/number}","notifications_url":"https://api.github.com/repos/genome/ptero-workflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/genome/ptero-workflow/labels{/name}","releases_url":"https://api.github.com/repos/genome/ptero-workflow/releases{/id}","created_at":"2014-04-01T19:56:33Z","updated_at":"2015-04-29T20:48:05Z","pushed_at":"2015-09-08T14:41:33Z","git_url":"git://github.com/genome/ptero-workflow.git","ssh_url":"git@github.com:genome/ptero-workflow.git","clone_url":"https://github.com/genome/ptero-workflow.git","svn_url":"https://github.com/genome/ptero-workflow","homepage":"","size":1987,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":22,"forks":3,"open_issues":22,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/genome/ptero-workflow/pulls/192"},"html":{"href":"https://github.com/genome/ptero-workflow/pull/192"},"issue":{"href":"https://api.github.com/repos/genome/ptero-workflow/issues/192"},"comments":{"href":"https://api.github.com/repos/genome/ptero-workflow/issues/192/comments"},"review_comments":{"href":"https://api.github.com/repos/genome/ptero-workflow/pulls/192/comments"},"review_comment":{"href":"https://api.github.com/repos/genome/ptero-workflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/genome/ptero-workflow/pulls/192/commits"},"statuses":{"href":"https://api.github.com/repos/genome/ptero-workflow/statuses/809f2665de868956ffa1ab25a4e41a2a531f38a3"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"mkiwala","id":108881,"avatar_url":"https://avatars.githubusercontent.com/u/108881?v=3","gravatar_id":"","url":"https://api.github.com/users/mkiwala","html_url":"https://github.com/mkiwala","followers_url":"https://api.github.com/users/mkiwala/followers","following_url":"https://api.github.com/users/mkiwala/following{/other_user}","gists_url":"https://api.github.com/users/mkiwala/gists{/gist_id}","starred_url":"https://api.github.com/users/mkiwala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkiwala/subscriptions","organizations_url":"https://api.github.com/users/mkiwala/orgs","repos_url":"https://api.github.com/users/mkiwala/repos","events_url":"https://api.github.com/users/mkiwala/events{/privacy}","received_events_url":"https://api.github.com/users/mkiwala/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":1,"additions":35,"deletions":4,"changed_files":2}}