v0.13.1-alpha — counts query optimization
Pre-releaseA focused performance patch on top of v0.13.0-alpha.
Changed
Drill-down counts query — 7.5× faster
The counts behind the /filter endpoint grouped by (facet_value, facet_display) — two 191-char VARCHARs — which bloated the aggregation temp table. Since the value→display mapping is 1:1 (slug→name, ID→title, or value === display for meta), the query now GROUP BY facet_value alone and takes the display via MIN(facet_display):
- Identical output — byte-for-byte the same buckets (verified on the live 100k stack: same 21 category buckets, same counts).
- 454ms → 60ms on the counts query, taking
resolve()p95 from ~465ms → ~63ms uncached on 100k products. COUNT(DISTINCT object_id)is kept (notCOUNT(*)) so a multi-row-per-object meta facet still counts each object once.
Together with the v0.13.0 result-set cache, the /filter path is now fast on both cold (~63ms) and repeat (sub-ms) hits. SQL shape is locked by a unit test.
Note:
EXPLAINreported both the old and new queries as "Using temporary; Using filesort" — only wall-clock measurement exposed the 7.5× gap. Measure, don't trust the plan.
Verification
- PHP: 121 tests / 269 assertions;
php -lclean - JS: 35 tests; build clean · Markdown: lint clean
- Live stack: identical buckets confirmed;
resolve()re-benchmarked at ~63ms p95
Upgrade
git pull && composer install && npm installNo schema change, no reindex, no behavior change — purely a faster query.
Full changelog: CHANGELOG.md