Skip to content

Fix(Perf): index order lines, check budget in one query and stop re-r… - #631

Open
Herafia wants to merge 2 commits into
11.0/bugfixesfrom
perf_order_form_and_tabs
Open

Herafia wants to merge 2 commits into
11.0/bugfixesfrom
perf_order_form_and_tabs

Conversation

@Herafia

@Herafia Herafia commented Nov 17, 2026

Copy link
Copy Markdown
Contributor
  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • Instance: GLPI 11.0 (e2e environment), order 2.12.12, debug mode off
  • Data: 2 000 computers, 20 budgets, 200 references, 5 000 orders, 51 180 order lines, 2 000 bills; one budget with 500 orders, one order with 1 000 units (600 delivered), one order with 50 references and 50 bills
  • Measured scenarios: central page, Management tab of an ordered computer and its save, order form, order detail, reception, associated items and bills tabs, orders tab of a budget and of a supplier, order list
  • Measurement method: median of 5 runs after a warm-up (browser Performance API); SQL from the MariaDB slow log at a zero threshold
  • SQL: index on glpi_plugin_order_orders_items.plugin_order_orders_id and glpi_plugin_order_orders.budgets_id (install and migration); over-budget check in one query instead of one SUM per order of the budget; reception tab uses the loaded line status instead of reading each line twice; bills tab and budget tab read bills, names and prices once; no isActivated() at init

SQL Queries

Scenario Without plugin Before After Difference
Order form (budget with 500 orders) - 652 149 -77.1 %
Order form, rows examined - 25 854 871 16 148 -99.9 %
Reception tab (1 000 units) - 3 036 106 -96.5 %
Bills tab (50 references) - 906 315 -65.2 %
Budget orders tab, rows examined - 1 038 484 7 019 -99.3 %
Order detail tab, rows examined - 215 459 13 974 -93.5 %
Management tab of an ordered computer 136 150 146 -2.7 %
glpi_plugins per request 8 12 10 -2

Response Times

Scenario Before After Difference
Order form (server) 1 990 ms 29 ms -98.5 %
Reception tab (server) 109 ms 50 ms -54.3 %
Bills tab (server) 88 ms 42 ms -52.6 %
Budget orders tab (server) 110 ms 26 ms -76.5 %

@Herafia Herafia self-assigned this Nov 17, 2026
@Herafia
Herafia requested review from a team, Mary-Clb, Rom1-B, RomainLvr and jdurand-teclib and removed request for a team and jdurand-teclib November 17, 2026 13:11

@Rom1-B Rom1-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order detail and associated items tabs still read each line through getReceptionStatus():

diff --git a/inc/link.class.php b/inc/link.class.php
@@ -294,7 +294,6 @@ class PluginOrderLink extends CommonDBChild
         $PluginOrderOrder_Item = new PluginOrderOrder_Item();
         $PluginOrderReference  = new PluginOrderReference();
-        $PluginOrderReception  = new PluginOrderReception();
 
@@ -417,7 +416,7 @@ class PluginOrderLink extends CommonDBChild
-            $entry['status'] = $PluginOrderReception->getReceptionStatus($detailID);
+            $entry['status'] = PluginOrderReception::getReceptionStatusLabel((int) $data["states_id"]);
diff --git a/inc/order_item.class.php b/inc/order_item.class.php
@@ -1185,6 +1185,7 @@ class PluginOrderOrder_Item extends CommonDBRelation
                 $table . '.price_ati',
+                $table . '.states_id',
             ],
@@ -1259,7 +1260,7 @@ class PluginOrderOrder_Item extends CommonDBRelation
-            $entry['status'] = $reception->getReceptionStatus($data["IDD"]);
+            $entry['status'] = PluginOrderReception::getReceptionStatusLabel((int) $data["states_id"]);

Comment thread tests/Units/OrderTest.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.

2 participants