{"action":"created","issue":{"url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth/issues/932","repository_url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth","labels_url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth/issues/932/labels{/name}","comments_url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth/issues/932/comments","events_url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth/issues/932/events","html_url":"https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/932","id":144290403,"number":932,"title":"Performance Issues returning users from large users table","user":{"login":"nathanpitman","id":694545,"avatar_url":"https://avatars.githubusercontent.com/u/694545?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanpitman","html_url":"https://github.com/nathanpitman","followers_url":"https://api.github.com/users/nathanpitman/followers","following_url":"https://api.github.com/users/nathanpitman/following{/other_user}","gists_url":"https://api.github.com/users/nathanpitman/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanpitman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanpitman/subscriptions","organizations_url":"https://api.github.com/users/nathanpitman/orgs","repos_url":"https://api.github.com/users/nathanpitman/repos","events_url":"https://api.github.com/users/nathanpitman/events{/privacy}","received_events_url":"https://api.github.com/users/nathanpitman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-29T14:55:46Z","updated_at":"2016-03-30T09:51:46Z","closed_at":null,"body":"I'm running into some big issues when returning a limited set of users from a large Ion Auth users table. I have ~500,000 users and most of those belong to a particular user group. When I query the database for these users using Ion Auth functions (even paginated to 50 at a time) the resulting query is taking upwards of 10 seconds to execute.\r\n\r\n```\r\nSELECT DISTINCT `users`.*, FROM_UNIXTIME(users.last_login) AS f_last_login\r\nFROM (`users`)\r\nINNER JOIN `users_groups` ON `users_groups`.`user_id`=`users`.`id`\r\nWHERE `users_groups`.`group_id` IN (5)\r\nORDER BY `id` desc\r\nLIMIT 50\r\n```\r\n\r\nI'm guessing the crux of the issue is the join on the users_groups table. Do you have any advice on how I can improve this? I don't really want to abandon Ion Auth. :/"},"comment":{"url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth/issues/comments/203353648","html_url":"https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/932#issuecomment-203353648","issue_url":"https://api.github.com/repos/benedmunds/CodeIgniter-Ion-Auth/issues/932","id":203353648,"user":{"login":"nathanpitman","id":694545,"avatar_url":"https://avatars.githubusercontent.com/u/694545?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanpitman","html_url":"https://github.com/nathanpitman","followers_url":"https://api.github.com/users/nathanpitman/followers","following_url":"https://api.github.com/users/nathanpitman/following{/other_user}","gists_url":"https://api.github.com/users/nathanpitman/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanpitman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanpitman/subscriptions","organizations_url":"https://api.github.com/users/nathanpitman/orgs","repos_url":"https://api.github.com/users/nathanpitman/repos","events_url":"https://api.github.com/users/nathanpitman/events{/privacy}","received_events_url":"https://api.github.com/users/nathanpitman/received_events","type":"User","site_admin":false},"created_at":"2016-03-30T09:51:46Z","updated_at":"2016-03-30T09:51:46Z","body":"My users_groups table is as per the install SQL: https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/2/sql/ion_auth.sql#L66-L76\r\n\r\nI'll give your suggestion a try though..."}}