Skip to content
Snippets Groups Projects

Optimize Projects sidebar performance

Closed gitlab-qa-bot requested to merge github/fork/jirutka/sidebar-perf into master

Created by: jirutka

Projects on sidebar contains their last activity, i.e. creation date of the last event associated with the project. Performance issue with the current implementation is that it generates extra query for every project in sidebar and every time when user open the Dashboard page. I have about 30 projects in my sidebar so that means 30 hits to database just to get last activity date of projects.

SELECT "events".* FROM "events" WHERE "events"."project_id" = 7 AND (author_id IS NOT NULL) ORDER BY events.created_at DESC LIMIT 1

This patch eliminates these extra queries entirely and thus significantly reduces load time of sidebar with many projects. Instead of querying for the last event to read its created_at, we can just read project’s updated_at attribute which is touched (i.e. updated) while any event that belongs to the project is saved (see http://goo.gl/X4mOJ for example).

Note: I’ve run tests on my machine with MRI 1.9.3-p327 and all passed.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Created by: vsizov

    +1

    By Administrator on 2013-01-02T09:08:38 (imported from GitLab project)

    By Administrator on 2013-01-02T09:08:38 (imported from GitLab)

  • Created by: dzaporozhets

    -1 for me.

    What we have:

    • changing 7 files
    • adding migration
    • update project row on every event creation/update/destroy (and what if we got event without project)

    What it solve

    • improve perfomance a bit

    I think we can just write a sql query to reduce amount of sql requests.

    By Administrator on 2013-01-02T10:18:59 (imported from GitLab project)

    By Administrator on 2013-01-02T10:18:59 (imported from GitLab)

  • Created by: vsizov

    you are right

    By Administrator on 2013-01-02T10:20:34 (imported from GitLab project)

    By Administrator on 2013-01-02T10:20:34 (imported from GitLab)

  • Created by: dzaporozhets

    I like performance patches but prefer a simplest solutions

    By Administrator on 2013-01-02T10:20:57 (imported from GitLab project)

    By Administrator on 2013-01-02T10:20:57 (imported from GitLab)

Please register or sign in to reply
Loading