{"action":"created","issue":{"url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1189","repository_url":"https://api.github.com/repos/rubygems/rubygems.org","labels_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1189/labels{/name}","comments_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1189/comments","events_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1189/events","html_url":"https://github.com/rubygems/rubygems.org/pull/1189","id":131699980,"number":1189,"title":"Eliminate 3N+1 query on Rubygems#index","user":{"login":"nateberkopec","id":845662,"avatar_url":"https://avatars.githubusercontent.com/u/845662?v=3","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-05T17:18:18Z","updated_at":"2016-03-04T02:19:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1189","html_url":"https://github.com/rubygems/rubygems.org/pull/1189","diff_url":"https://github.com/rubygems/rubygems.org/pull/1189.diff","patch_url":"https://github.com/rubygems/rubygems.org/pull/1189.patch"},"body":"Version#most_recent can trigger up to 3 SQL queries per Rubygem instance in a rendered collection.\r\n\r\nBefore:\r\n![screen shot 2016-02-05 at 12 14 45 pm](https://cloud.githubusercontent.com/assets/845662/12853448/1a0fbc96-cc02-11e5-8945-45a48a14d438.png)\r\n\r\nAfter:\r\n![screen shot 2016-02-05 at 12 15 37 pm](https://cloud.githubusercontent.com/assets/845662/12853470/3692e320-cc02-11e5-946b-79c582173520.png)\r\n\r\nThis speeds up the Rubygems#index action for me by ~33% locally, and eliminates dozens of cached and uncached queries. \r\n\r\nUnfortunately, there is an N+1 situation anywhere Version#most_recent is used when iterating over a collection of Rubygems. This happens in a lot of places. I can fix those other places once this fix is approved."},"comment":{"url":"https://api.github.com/repos/rubygems/rubygems.org/issues/comments/192064733","html_url":"https://github.com/rubygems/rubygems.org/pull/1189#issuecomment-192064733","issue_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1189","id":192064733,"user":{"login":"nateberkopec","id":845662,"avatar_url":"https://avatars.githubusercontent.com/u/845662?v=3","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"created_at":"2016-03-04T02:19:40Z","updated_at":"2016-03-04T02:19:40Z","body":"Oh whoops - is the reason no one's commented here because all of this is done in ElasticSearch now? Just realized that's probably what's happening.\r\n\r\nIf this still may be useful, I'm 80% of the way to an all-SQL solution."}}