Engineering · Performance

Three reads that needed nothing from each other

The status call every page fires after paint ran three database reads in a line that needed nothing from each other. One wait now, and the first rows show it.


Every page on the public site, once it has painted, asks the server one small question: is this person signed in, and whose brand is this? The answer swaps the sign-in button for an open-the-app one, and on a white-labelled install it paints the operator’s mark instead of ours. The sign-in screen and the till’s code keypad paint the brand from the same answer before anybody has a session, and the staff app boots on it. It is the most-called route we have that nobody ever notices.

Sixteen rows on the page board put it at 181 milliseconds inside the worker, measured from the UK. The handler was three database reads in a line: look up the session, read the five brand settings, count the users to decide whether the install still needs setting up. Each read is a round trip to a database on another continent, and not one of them needed the answer to the one before it. A signed-in person paid three of those trips in series; a stranger paid two.

The fix is the same shape as one we made inside the session lookup itself two months ago, when four reads keyed on the same token were folded into one batch. Here the three reads become one wait. A settings table that does not exist yet still yields an empty brand, as it always did; the setup flag is still the user count; the brand still resolves through the same two helpers. Nothing about the answer changed, only how long it took to assemble.

The first two rows on the new release read 119 milliseconds against the 181 baseline. That is a third off, not two thirds, and the arithmetic says why: one wait over three reads of unequal length is the longest of the three, not the sum divided by three, and the session batch is the long leg. Two rows is a direction rather than a number, so the baseline stays written down until there are enough to say more.

Why does a post-paint call matter at all, if it never holds up a paint? Because the pages that were over budget last night all named it as their slowest call, and the next person reading that board would reasonably go looking for a slow page. It was not the page. It was the one route under every page, and shaving it is the kind of work that moves nothing on a benchmark and something on every visit.


Try it on tonight’s service.

Nothing to install, no card. Not better by the weekend? Close the tab.