Skip to content

Perf: paginate tabs, batch queries, evaluate dynamic groups once - #138

Open
Lainow wants to merge 2 commits into
11.0/bugfixesfrom
fix/performance-tabs-dynamic-groups
Open

Lainow wants to merge 2 commits into
11.0/bugfixesfrom
fix/performance-tabs-dynamic-groups

Conversation

@Lainow

@Lainow Lainow commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.

Description

Several plugin tabs ran 2 to 3 SQL queries per displayed line and rendered every line, so they grew with the data. They now load one page (core pager, glpilist_limit lines) in a few queries.

  • Static groups and Contact logs tabs: one JOIN query per page plus a COUNT, newest contact logs first.
  • Computer groups tab of a param: groups, static counts (GROUP BY) and dynamic searches in 3 queries.
  • Agent parameters (task.class.php): each dynamic group is evaluated once per request, skipped when its params are already found, and the result is memoized per computer.
  • plugin_init: removed Plugin::isPluginActive() (2 queries on every HTTP request).
  • ajax/agent.php: the session lock is released before calling the agent.
  • Inventory request: credential types are sent once (DISTINCT), and the button shows an error on failure or timeout instead of spinning.

Visible changes:

  • these tabs are paginated (20 lines per page by default);
  • contact logs are sorted newest first;
  • a line whose linked item is gone shows an empty name instead of the previous line's name.

Benchmark

Benchmark setup:

  • GLPI 11.0/bugfixes, e2e database, debug mode and Xdebug off;
  • 2 000 computers, one static group of 2 000 members, 50 000 contact logs;
  • 5 runs per scenario after a warm-up, medians reported;
  • SQL counted from the MariaDB query log.
Scenario SQL queries before SQL queries after Fully loaded before Fully loaded after
S7 Computer group, Static groups tab (2 000 members) 6 131 129 (-98 %) 668 ms 236 ms (-65 %)
S10 Database param, Contact logs tab (2 500 lines) 5 124 121 (-98 %) 426 ms 215 ms (-50 %)
S3 Agent, Contact logs tab (1 250 lines) 2 622 119 (-95 %) 325 ms 212 ms (-35 %)
S9 Database param, Computer groups tab 577 275 (-52 %) 195 ms 160 ms (not significant)
S11 Request database inventory 426 327 (-23 %) 228 ms 143 ms (not significant)

Other measurements:

  • Response size: S7 drops from 1.9 MB to 38 KB, and S10 from 954 KB to 10 KB.
  • S11: 38 → 27 Computer searches.
  • Every page: 2 fewer queries per HTTP request.

What remains:

  • the cost of S9, and of the groups list, comes from the Computer search run for each dynamic group;
  • that is not changed here, because it would change the default display.

- Static groups and Contact logs tabs: one JOIN query per page instead
  of 2 to 3 queries per line, with the core pager
- Computer groups tab of a param: counts and searches in 3 queries
- Agent parameters: evaluate each dynamic group once per request
- Remove the Plugin::isPluginActive() check from plugin_init
- Release the session lock before calling the agent
- Distinct credential types, JS error callback on inventory request
@Rom1-B
Rom1-B requested review from a team, Herafia, Mary-Clb and MyvTsv and removed request for a team November 18, 2026 13:05
Herafia
Herafia previously approved these changes Nov 20, 2026
Comment thread ajax/agent.php Resolved
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.

3 participants