Possible optimisation on config reads?

Created on 25 June 2019, over 5 years ago
Updated 30 April 2023, over 1 year ago

On a multilingual website, while reviewing the SQL queries done for a specific operation, we noticed that config table is getting requested twice for the same config names: once for default collection and once for the current language.

Examples:

SELECT name, data FROM config WHERE collection = 'language.en' AND name IN ( 'acq_sku_stock.settings' )
SELECT name, data FROM config WHERE collection = '' AND name IN ( 'acq_sku_stock.settings' )

SELECT name, data FROM config WHERE collection = 'language.en' AND name IN ( 'pathauto.pattern.content_pathauto', 'pathauto.pattern.department_page_path_pattern', 'pathauto.pattern.promotion_url_alias', 'pathauto.pattern.static_html_pattern', 'pathauto.pattern.store_arabic', 'pathauto.pattern.store_english' )
SELECT name, data FROM config WHERE collection = '' AND name IN ( 'pathauto.pattern.content_pathauto', 'pathauto.pattern.department_page_path_pattern', 'pathauto.pattern.promotion_url_alias', 'pathauto.pattern.static_html_pattern', 'pathauto.pattern.store_arabic', 'pathauto.pattern.store_english' )

SELECT name, data FROM config WHERE collection = 'language.en' AND name IN ( 'taxonomy.settings' )
SELECT name, data FROM config WHERE collection = '' AND name IN ( 'taxonomy.settings' )

SELECT name, data FROM config WHERE collection = 'language.en' AND name IN ( 'scheduled_updates.settings' )
SELECT name, data FROM config WHERE collection = '' AND name IN ( 'scheduled_updates.settings' )

SELECT name, data FROM config WHERE collection = 'language.en' AND name IN ( 'alshaya_acm_product_category.settings' )
SELECT name, data FROM config WHERE collection = '' AND name IN ( 'alshaya_acm_product_category.settings' )

One query is executed from Drupal\Core\Config\ConfigFactory::doLoadMultiple.
The other one is executed from Drupal\language\Config\LanguageConfigFactoryOverride::loadOverrides.

Would it make sense to merge these two queries into a single one?

πŸ“Œ Task
Status

Active

Version

9.5

Component
ConfigurationΒ  β†’

Last updated 7 days ago

Created by

πŸ‡«πŸ‡·France sdelbosc

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Open on Drupal.org β†’
    Environment: PHP 8.1 & MySQL 5.7
    29:56
    29:17
    Queued
  • @angrytoast opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States angrytoast Princeton, NJ

    It looks like currently when loading config on a multilingual site, LanguageConfigFactoryOverride::loadOverrides will always run even if the current negotiated language is the default language. This will check for a language override that won't exist because the default language doesn't have a collection--if my site's default language is en, the imported config values will be under empty collection '', not language.en.

    As-is, it tries to load a config by language.en, doesn't find any overrides, and then writes this to cache as a serialized FALSE value, which is then filtered and discarded in the process.

    It seems safe to skip the whole process if we are looking at the default site language?

  • last update over 1 year ago
    30,327 pass, 5 fail
Production build 0.71.5 2024