150 DB queries per lesson page - normal?

Re: 150 DB queries per lesson page - normal?

by Tim Hunt -
Number of replies: 0
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

All the SHOW COLUMNS queries don't really count (although it would still be good to fix Moodle so that it caches this rather than re-querying it each time).

What exactly are you measuring here? Is it a single page-load, or does going from one page in a lesson to the next actually cause two DB queries (e.g. a POST that redirects to a GET)? That would explain why most queries happen twice.

Most page-loads in Moodle require about 20-30 DB queries, depending on the complexity of the page, and what role you are logged in as (it takes more DB queries to build the settings navigation for admins). That number should be O(1). What I mean is, if a page shows a report with n rows, then the number of DB queries should be fixed, not proportional to n.