I haven't done web work in a while but am I the only one who thinks that's a ridiculously high number for a single page?
I haven't done web work in a while but am I the only one who thinks that's a ridiculously high number for a single page?
Any FB page probably also needs that many.
For most sites, 200 queries is way, way, way too much.
A complete log of the 200+ SQL statements used in generating the page above can be seen at http://sqlite.org/tmp/timeline-sql-log.html
The list of check-ins is computed by a single query. But that query then tosses the list over the wall to another subsystem which generates content for each check-in. And several queries are required for each check-in to extract the relevant information needed for display.
The timeline example above is an information-rich page. Perhaps it could be generated using fewer than 200 SQL statements. But SQL against an SQLite database is so cheap that it has never really been a factor. You can see at the bottom of the page that it was generated in about 25 milliseconds. Profiling indicates that very few of those 25 milliseconds were spent inside the database engine.
It is, but it does happen, usually due to design decisions.
When I was still young enough to do PHP (about a decade ago), one of my largest projects was a domain-specific CMS for code collaboration. It was all working fine on my development system, but in production, every page loaded for at least 4-5 seconds. I inspected into the DB queries that were used to build a single page, and found a lot of duplicate
SELECT * FROM {table} WHERE id = {id};
because of how the model classes were built. Since it was too late to change the architecture, I sent these types of statements through a simple cache and brought the amount of queries per page down from a few hundred to below 10.