3 ms·
> Each dynamic page does roughly 200 SQL statements. I haven't done web work in a while but am I the only one who thinks that's a ridiculously high number for
by jeremy_wiebe 10y ago
> Each dynamic page does roughly 200 SQL statements.
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?
- kazagistar 10y agoName widget asks the name endpoint, date widget asks the date endpoint, age widget asks the age endpoint...
- pmontra 10y agoMore or less the Kibana dashboard's way of doing things, which destroys the Elasticsearch machine and forces setting up a cluster with GB of RAM and multiple CPUs even if it sits doing nothing between refreshes. The dashboard could serialize the queries and that web service could combine those queries into one, get the name, date and age and demux the result to the single widgets.
- the_duke 10y agoIt's correct if you are using some framework like Drupal, and caching is not enabled. Any FB page probably also needs that many. For most sites, 200 queries is way, way, way too much.
- majewsky 10y ago> [Is 200 SQL statements] a ridiculously high number for a single page? 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.
- SQLite 10y agoAn example is http://sqlite.org/src/timeline http://sqlite.org/src/timeline 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 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.
- jstimpfle 10y agoThis is called the "n+1 queries" problem.