Skip to content

Avoid locale-aware project config sorting on PostgreSQL - #19572

Merged
brandonkelly merged 1 commit into
craftcms:5.xfrom
boboldehampsink:feature/project-config-postgres-sort
Sep 8, 2026
Merged

Avoid locale-aware project config sorting on PostgreSQL#19572
brandonkelly merged 1 commit into
craftcms:5.xfrom
boboldehampsink:feature/project-config-postgres-sort

Conversation

@boboldehampsink

Copy link
Copy Markdown
Contributor

Description

Reloading project config on an internal config cache miss orders all stored paths using the database’s default collation. On PostgreSQL with a locale-aware collation, this sort can dominate the reload time and delay both control panel and frontend requests.

On an affected production database containing 38,633 project-config rows, the normal query took approximately 790 ms, compared with 55 ms for the same query ordered by path COLLATE "C". Most of the original query time was spent sorting.

Use PostgreSQL’s bytewise C collation specifically when ordering paths in _loadInternalConfig(). This preserves the parent-before-child ordering needed to reconstruct nested config without paying for language-aware sorting of machine identifiers. The existing config cleanup still applies its natural key sorting afterward.

The change requires no schema migration and leaves MySQL ordering unchanged. It targets config-cache misses; it does not imply that every slow request reloads project config.

Related issues

No existing GitHub issue.

@brandonkelly
brandonkelly merged commit b85efab into craftcms:5.x Sep 8, 2026
11 checks passed
@brandonkelly

Copy link
Copy Markdown
Member

Thanks!

brandonkelly added a commit that referenced this pull request Sep 8, 2026
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