{"action":"opened","issue":{"url":"https://api.github.com/repos/transitland/transitland-datastore/issues/283","labels_url":"https://api.github.com/repos/transitland/transitland-datastore/issues/283/labels{/name}","comments_url":"https://api.github.com/repos/transitland/transitland-datastore/issues/283/comments","events_url":"https://api.github.com/repos/transitland/transitland-datastore/issues/283/events","html_url":"https://github.com/transitland/transitland-datastore/issues/283","id":123737654,"number":283,"title":"improve performance of ScheduleStopPair where_origin_bbox query","user":{"login":"drewda","id":212369,"avatar_url":"https://avatars.githubusercontent.com/u/212369?v=3","gravatar_id":"","url":"https://api.github.com/users/drewda","html_url":"https://github.com/drewda","followers_url":"https://api.github.com/users/drewda/followers","following_url":"https://api.github.com/users/drewda/following{/other_user}","gists_url":"https://api.github.com/users/drewda/gists{/gist_id}","starred_url":"https://api.github.com/users/drewda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewda/subscriptions","organizations_url":"https://api.github.com/users/drewda/orgs","repos_url":"https://api.github.com/users/drewda/repos","events_url":"https://api.github.com/users/drewda/events{/privacy}","received_events_url":"https://api.github.com/users/drewda/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/transitland/transitland-datastore/labels/performance%20improvements","name":"performance improvements","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-23T23:48:12Z","updated_at":"2015-12-23T23:48:12Z","closed_at":null,"body":"Based on brief Postgres console investigations, @rmarianski thinks the query might be faster as a JOIN, rather than an IN subquery (as ActiveRecord runs it right now)\n\nSome resources that may help:\n\n- squeel gem's way of representing JOINs in ActiveRecord queries: https://github.com/activerecord-hackery/squeel#joins\n- PgHero dashboard on dev: http://dev.transit.land/admin/postgres_dashboard\n- \"Postgres Up and Running\" e-book, chapter on performance: https://drive.google.com/a/mapzen.com/file/d/0B42JvyWtPsTDQjBDZGRUVE9KWlE/view?usp=sharing"}}