Resource path upsert queries causing high database load
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
Every time an asset bundle URL is requested, there is an upsert into the resourcepaths table. On medium-to-large sites with many plugins and asset bundles, this can lead to significant database load, especially when multiple people are working in the control panel or bundles are included in front-end templates.
The offending code is located in craft\web\AssetManager::hash().
Steps to reproduce
- Visit any control panel page.
- Check query log.
Additional info
- Craft version: Craft Pro 3.7.13
- PHP version: 7.4.23
- Database driver & version: MySQL 5.5.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in craft\web\AssetManager::hash() and reproduce the behavior by visiting a control panel page while watching the query log. Trace the upsert into the resourcepaths table and determine when it repeats for asset bundle URLs. Done means the repeated requests no longer cause the reported unnecessary database load, with the query behavior verified in the reproduction steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php
- Domain
- backend, databases, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100