craftcms / craftcms/cms

Resource path upsert queries causing high database load

Open
#9,847 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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
  1. Visit any control panel page.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.