{"action":"created","issue":{"url":"https://api.github.com/repos/resque/resque/issues/1420","repository_url":"https://api.github.com/repos/resque/resque","labels_url":"https://api.github.com/repos/resque/resque/issues/1420/labels{/name}","comments_url":"https://api.github.com/repos/resque/resque/issues/1420/comments","events_url":"https://api.github.com/repos/resque/resque/issues/1420/events","html_url":"https://github.com/resque/resque/pull/1420","id":135538242,"number":1420,"title":"Avoid N+1 query by caching job in Worker instance","user":{"login":"fw42","id":2072686,"avatar_url":"https://avatars.githubusercontent.com/u/2072686?v=3","gravatar_id":"","url":"https://api.github.com/users/fw42","html_url":"https://github.com/fw42","followers_url":"https://api.github.com/users/fw42/followers","following_url":"https://api.github.com/users/fw42/following{/other_user}","gists_url":"https://api.github.com/users/fw42/gists{/gist_id}","starred_url":"https://api.github.com/users/fw42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fw42/subscriptions","organizations_url":"https://api.github.com/users/fw42/orgs","repos_url":"https://api.github.com/users/fw42/repos","events_url":"https://api.github.com/users/fw42/events{/privacy}","received_events_url":"https://api.github.com/users/fw42/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-22T20:44:59Z","updated_at":"2016-02-22T21:56:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/resque/resque/pulls/1420","html_url":"https://github.com/resque/resque/pull/1420","diff_url":"https://github.com/resque/resque/pull/1420.diff","patch_url":"https://github.com/resque/resque/pull/1420.patch"},"body":"This is essentially https://github.com/Shopify/resque/pull/11.\r\n\r\nThe problem that we run into is that we call `Reqsue::Worker.working` (at which point we already know all of the jobs, since they are part of the serialization that we already fetched from the Redis server). Then, later, for each of those working workers, we call `#job`, which fetches the current job again with an additional Redis call.\r\n\r\nThis PR adds an optional flag to the `#job` method that allows you to avoid this kind of N+1 query and use the cached previous value. The default is to not do that, so this should be backwards compatible.\r\n\r\nThoughts?\r\n\r\n@Sirupsen @steveklabnik "},"comment":{"url":"https://api.github.com/repos/resque/resque/issues/comments/187404330","html_url":"https://github.com/resque/resque/pull/1420#issuecomment-187404330","issue_url":"https://api.github.com/repos/resque/resque/issues/1420","id":187404330,"user":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T21:56:34Z","updated_at":"2016-02-22T21:56:34Z","body":"Seems pretty reasonable at first glance. I'm not sure if there's a better way to do this, but adding an optional param seems like a very small change, even if it's not the best possible way."}}