Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance suggestions for stats feature #201

Open
polothy opened this issue Jun 13, 2016 · 1 comment
Open

Performance suggestions for stats feature #201

polothy opened this issue Jun 13, 2016 · 1 comment
Labels

Comments

@polothy
Copy link

polothy commented Jun 13, 2016

Hello - found some potential performance problems if this plugin was used on a very active site:

  • In auth_plugin_googleoauth2::get_stats function, the query to auth_googleoauth2_logins table could return a lot of records. An improvement would be to use a count SQL query, EG: SELECT subtype, COUNT(id) logins FROM {auth_googleoauth2_logins} WHERE time > :time GROUP BY subtype and the subtype that is null would be for your moodle logins. Think you would have to use get_recordset_sql to run that SQL as get_records_sql likely wouldn't like the null subtype.
  • In the auth_googleoauth2_observer, ideally the get_record on user table just pulls down their auth field instead of the whole record, EG: use $DB->get_field(...) instead. You might be able to get away with using $USER global as well and avoid the DB read altogether.
  • The auth_googleoauth2_logins table is never cleaned, so could get quite large over time. I would suggest adding a scheduled task to delete old records. Would probably look very similar to \logstore_standard\task\cleanup_task.
  • Adding an index to the time column on the auth_googleoauth2_logins table would really improve query performance once the table size gets larger.

Please let me know if anything is unclear, cheers!

@mouneyrac
Copy link
Collaborator

All clear, feel free to send a PR, cheers :)

@mouneyrac mouneyrac added the Bug label Jun 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants