Skip to content

Optimize query count in notification.views.notices #33

@zsiciarz

Description

@zsiciarz

Currently the notices() view does not retrieve notice types together with notices for current user. If the template processes each notice like below:

{% for notice in notices %}
  {{ notice.notice_type.display }}
{% endfor %}

each notice_type is fetched separately from the database. When the user is displayed a lot of notifications, query count will quickly increase. I propose a patch to optimize away most of these queries by using select_related() in the view function.

Patch: http://gist.github.com/429952

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions