Count queries on the paths an audit actually finds them on, not only on the hold path
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3620377. -->
Reported by: [mably](https://www.drupal.org/user/3375160)
Related to !330
>>>
<h3>Problem/Motivation</h3>
<p>PlaceHoldCostTest measures what the hold path costs, and measures it against the size of the party rather than per booking, which is the reasoning its own docblock gives for catching <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/yoyaku/-/work_items/3616341" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/yoyaku/-/work_items/3616341</a></span>. Nothing does the same for any other path.</p>
<p>That gap is not theoretical. While fixing <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/yoyaku/-/work_items/3620326" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/yoyaku/-/work_items/3620326</a></span> an extra call to getRunningBookingIds() was added to a page. The lookup behind it runs a paged query and resolves each instance's transaction one at a time: with its page size of fifty it costs 102 queries a call, so calling it twice cost more than the fifty entity loads the batching had just saved. The page ended up about 52 queries worse while the commit claimed to remove an N+1.</p>
<p>It passed everything: phpstan, phpcs with DrupalPractice, the kernel suite, and eight consecutive green pipelines. No gate in the toolchain counts queries, so nothing could have caught it. It was found by reading the diff.</p>
<p>The same blind spot is where every performance finding in that audit lived: a section read per area on the seat map's cache fill, an entity load per option in the venue-scoped widget, a grade load per row in the configuration area table. All of them admin screens or cache fills, none of them measured.</p>
<h3>Proposed resolution</h3>
<p>Extend the Database::startLog() pattern already used by PlaceHoldCostTest to the paths the audit touched, asserted the way that class asserts them: as a budget that does not grow with the size of the input.</p>
<ul>
<li>The venue map's settled-state fill, which must not grow with the number of areas.</li>
<li>The venue-scoped options widget, which must not grow with the number of options.</li>
<li>The configuration area table, which must not grow with the number of rows.</li>
</ul>
<p>Each wants two fixtures of different sizes, so that what is asserted is that the count does not follow the input rather than that it equals a particular number.</p>
<p>One trap to write down while it is known: a kernel test cannot see the cache backend's own queries, because the backend there is cache.backend.memory. The assertion has to be on the reads the fill performs, never on the cache get or set.</p>
<h3>Remaining tasks</h3>
<p>Whether the repeated-costly-call detector written during that audit belongs in CI as well as in a test is worth deciding separately. A test that pins counts catches the effect; a detector catches the shape.</p>
<h3>User interface changes</h3>
<p>None.</p>
<h3>API changes</h3>
<p>None.</p>
<h3>Data model changes</h3>
<p>None.</p>
<p>AI-Generated: Yes (Claude Code was used to help draft this issue summary. I reviewed it before posting; there is no code on this issue yet.)</p>
issue
GitLab AI Context
Project: project/yoyaku
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/yoyaku/-/raw/1.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/yoyaku
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD