Problem

Drupal 7 serves the numbers of the "Explore languages" page from a cache it rebuilds hourly on cron (and clears for a language after an import), with one grouped query for the translation and suggestion counts of every language. On 3.0.x the page runs four uncached count queries per language on every render, one of them a full count of the source strings table, and the page is rendered again after every translation saved on the site. With a hundred languages and millions of strings that is a few hundred heavy queries per view.

Proposed resolution

  • The page takes every number from the statistics service's cached grouped queries (translations and suggestions per language, contributors per language), with the live string count Drupal 7 also used.
  • The statistics service gets a cache tag and a clearCache(); the page carries the tag and the cache lifetime, so a cleared cache reaches the rendered page and nothing stays older than the lifetime.
  • An import clears the statistics, like on Drupal 7 (the todo left in the import form).
  • The uncached per-language query goes, nothing else used it.

Tests

Drupal 7 first: testLanguageStatisticsCache() primes the page, approves a translation on the site, checks the page still shows the cached numbers, runs cron and checks the rebuilt numbers. Ported as L10nLanguageStatisticsTest, where the cache lifetime ending is the rebuild and an import shows up right away.

LLM disclosure

LLM was used to find, diagnose explain and fix this issue. With human review.

Comments

gábor hojtsy created an issue. See original summary.

  • 4d5f6ad1 committed on 7.x-1.x
    Issue #3621666: Explore languages runs uncached count queries per...

  • 8e82f470 committed on 3.0.x
    fix #3621666: Explore languages runs uncached count queries per language...
gábor hojtsy’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.