Skip to content

SiteVars makes too many queries #43

@veselosky

Description

@veselosky

Observed Behavior

Calculating and displaying the copyright notice for a page makes repeated queries to the SiteVars table, both in the template tags and in the models (MediaObject and AbstractOpenGraph).

The get_template_names and get_context_data methods of the views also make repeated SiteVar queries to look up template names.

In list views, the pagination methods make separate queries for site pagination defaults.

Expected Behavior

SiteVars should be cached and the table should be accessed no more than once per request.

Probably the "get_value" should be either removed entirely to prevent temptation, or modified so that it makes no database queries but only accesses the cached values.

It might be convenient if site.vars was subscriptable, allowing you to access a site var as site.vars["base_template"]. Again, this should access the cache and not produce a database query. Unfortunately that would interfere with Django's default queryset slicing. Best not to change Django's default behavior, that would be confusing for users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIssue that degrades performance without affecting functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions