Skip to content

[6.x] Lowercase what an equals where is looking for once - #15894

Merged
jasonvarga merged 2 commits into
statamic:6.xfrom
DanielDarrenJones:perf/6x-stache-equals-where
Nov 13, 2026
Merged

jasonvarga merged 2 commits into
statamic:6.xfrom
DanielDarrenJones:perf/6x-stache-equals-where

Conversation

@DanielDarrenJones

Copy link
Copy Markdown
Contributor

where('field', $value) on a Stache query lowercases the value it's looking for again for every item it's compared with.

filterWhereBasic() calls filterTestEquals($item, $value) for each value in the index, through a method name it builds each time, and that method lowercases both sides. The value being looked for is the same throughout. A front-end page here makes 90,000 to 200,000 of those calls, which comes to 15 to 30 ms.

For = with a string, number, boolean or null, the value is now lowercased once and each item is compared with the same expression filterTestEquals() uses. Everything else goes the way it did: other operators, values that aren't scalar (dates, arrays), and any query builder that has its own filterTestEquals().

Numbers

Filtering 2,000 index values by equality: 0.31 ms before, 0.10 ms after, whether the values are booleans, short strings or ids.

Whole requests, each in its own process, four alternating rounds of eight:

before after
localized page 281.5 ms 265.3 ms -5.7%
CP entries listing 399.0 ms 380.8 ms -4.6%
products index 364.8 ms 351.8 ms -3.6%
articles index 470.1 ms 454.5 ms -3.3%
category 457.2 ms 443.9 ms -2.9%
article 393.1 ms 382.1 ms -2.8%

Each of those differences is under twice the run's noise taken on its own; they all go the same way and are the size the direct timing predicts. Every response is byte for byte the same.

Tests

Nothing here can fail without the change, since it isn't meant to change any result. The tests pin what equals means so that it stays that way: twelve values (case, a trailing space, null and empty, booleans, numbers as numbers and as strings, accents), a date, and a query builder with its own filterTestEquals() still having it used.

@jasonvarga
jasonvarga merged commit eee8e34 into statamic:6.x Nov 13, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants