Identical db_select() queries re-built during a page request

Created on 28 November 2008, about 16 years ago
Updated 15 January 2025, 20 days ago

On #324313: Load multiple nodes and terms at once we benchmarked a front page with 30 nodes, with and without the node_load() select query converted to dbtng. http://drupal.org/node/324313#comment-1128706 has the benchmarks and an example patch.

It turns out that db_select() adds ~1ms of processing each time the function is called compared to the current code. When loading a single node this is only about a 1-2% hit, - but on a front page with 30 nodes, it adds 30ms to the processing time - on my machine that page can take about 230ms to load, so it's about a 6-7% hit. Not so good. If the multiple load patch goes in, then it won't be a problem for node queries - but as we convert more queries which are run mulitple times per page request to dbtng we could notice a slowdown.

Since the same query is being built each time in this case, I'm wondering if we could some how cache the built query - this would need to be keyed by something, since obviously there's nothing stopping the same function being called with different arguments on the same page request. No ideas as to how, but opening this issue so the information doesn't get lost.

Feature request
Status

Closed: outdated

Version

11.0 🔥

Component

database system

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024