Skip to content

Perf: read the configuration once per request - #180

Open
Lainow wants to merge 1 commit into
11.0/bugfixesfrom
perf/cache-configuration
Open

Lainow wants to merge 1 commit into
11.0/bugfixesfrom
perf/cache-configuration

Conversation

@Lainow

@Lainow Lainow commented Nov 13, 2026

Copy link
Copy Markdown

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.

Description

Each generated number read the plugin configuration again: 9 queries per asset. The generation switch, the per-type rows and the enabled itemtypes are now read once per request. The cache is cleared when a configuration is saved, added or removed. The counter and its reset date are still read from the database for each number.

Benchmark

GLPI 11.0, 2 000 computers, generation on for computers.

Scenario SQL before SQL after Time before Time after
Massive action "Regenerate inventory number", 50 computers 1 142 queries (450 on plugin tables) 844 (152) 940 ms 925 ms (not significant)
Computer creation (number generated), plugin queries 7 5 39 ms within noise

This is a small gain: most of the time is GLPI updating each asset.

Tests

A new test changes the template and the generation switch between two generations in the same process. It checks that each change is seen and that the numbers stay consecutive.

- Cache the generation switch, the per-type configuration rows and the
  enabled itemtypes for the request, cleared when a configuration is
  saved, added or removed
- The counter and its reset date are still read from the database for
  each generated number
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.

1 participant