I was just looking at my server logs, and it appears that for every page I load in Moodle (e.g., going from one page in a lesson to another), there are between 100 and 300 database queries. Is this normal, or does it indicate that something really screwy is going on?
I've attached a copy of the server log for a single pageload. One notable feature is the two updates to mdl_sessions, which included ~75k of binary data each (removed from the uploaded log to save space).
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.