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

/moderator/dashboard: optimize sql queries #2934

Merged
merged 3 commits into from Mar 23, 2017

Conversation

evazion
Copy link
Member

@evazion evazion commented Mar 23, 2017

This optimizes the http://danbooru.donmai.us/moderator/dashboard page in two ways:

  • Adds created_at indexes that were missing on a few version tables.
  • Converts the queries to use active record instead of raw sql. This fixes some issues with users being loaded one-by-one in multiple places. Doing this cuts the number of sql queries executed by the page in half.

* Converts queries to use active record instead of raw sql. This ensures
  that user objects are loaded by rails in the join, so that we
  don't have to issue `User.find` calls to load users one-by-one.

* Use `.includes` to preload associations used in the view, to avoid
  additional N+1 query problems (primarily, calls to link_to_user
  also causing users to be loaded one-by-one).
…sions,

This optimizes queries on /moderator/dashboard that filter by creation date.
@r888888888 r888888888 merged commit f30f21f into danbooru:master Mar 23, 2017
@evazion evazion deleted the opt-mod-dashboard branch March 27, 2017 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants