Moodle

Superfluous queries when listing categories on the front page

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.4
  • Fix Version/s: 1.9.6, 2.0
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

Inside course/lib.php:print_category_info(), there's the following query:

$coursecount = count_records('course') <= FRONTPAGECOURSELIMIT;

This unfortunately gets run every time we recurse into another category, but it really only needs to be checked once.

It can have a very big impact on a site which uses lots of categories and nested ones too. On one site, this has taken the number of queries on the front page from 383 down to 223.

The attached patch is against 1.9.

Activity

Hide
Sam Hemelryk added a comment -

Checked it out, good spotting, 1_9 and HEAD both fine. Thanks

Show
Sam Hemelryk added a comment - Checked it out, good spotting, 1_9 and HEAD both fine. Thanks

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: