Value lookups by items_id do not use the itemtype index and scan the whole values table
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 75/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- mariadb, php
- Bereich
- database, performance
Rechercherichtung
Lies zuerst PluginFieldsField::prepareHtmlFields() und PluginFieldsContainer::updateFieldsValues(), suche dann die anderen im Speicherpfad erwähnten Aufrufe von getFromDBByCrit(). Prüfe, wie jede Abfrage ihren Elementtyp erhält, und vergleiche den Abfrageplan mit der gemeldeten EXPLAIN-Reproduktion. Das Ziel ist erreicht, wenn diese Abfragen den vorhandenen zusammengesetzten Index verwenden können und der vollständige Scan der großen Tabelle vermieden wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
GLPI Version
11.0.11
Plugin version
1.24.6. The same code is in 1.25.0 and on main.
Bug description
The values table of each container (for example glpi_plugin_fields_ticketticketdetails) has the unique index itemtype_item_container (itemtype, items_id, plugin_fields_containers_id) and no other index on items_id. Several lookups filter on items_id without itemtype, so the index cannot be used and every call reads the whole table:
PluginFieldsField::prepareHtmlFields(),$obj->find(['plugin_fields_containers_id' => ..., 'items_id' => ...]), run on every display of an item that has a container.PluginFieldsContainer,getFromDBByCrit(['items_id' => $items_id])in the save path (4 places, for example inupdateFieldsValues()).
With 500,000 tickets and about 290,000 rows in the ticket container table, the first query read about 290,000 rows per call and took 156 ms on average at low load. Under heavy load the average rose to between 3.2 and 5.1 s per call. It was the fourth most expensive statement on the server at low load, and opening a ticket was slowed down by it.
Relevant log output
calls | total ms | avg ms | rows examined | no index | statement
268 | 41881 | 156.3 | 77890984 | 268 | SELECT * FROM `glpi_plugin_fields_ticketticketdetails` WHERE `plugin_fields_containers_id` = ? AND `items_id` = ?
430 | 745460 | 1733.6 | 124974340 | 430 | SELECT `id` FROM `glpi_plugin_fields_ticketticketdetails` WHERE `items_id` = ?
(performance_schema statement digests; the second line is from a step under heavy load)
Steps To reproduce
- Create a container on tickets with a few fields.
- Have a large number of tickets with values in it (hundreds of thousands).
- Open a ticket and run
EXPLAIN SELECT * FROM glpi_plugin_fields_ticketticketdetails WHERE plugin_fields_containers_id = 1 AND items_id = 12345;
Expected: the lookup uses the unique index.
Actual: no index is used and the whole table is read.
Your GLPI setup information
Docker, PHP 8.x with Apache prefork, MariaDB 10.11 with an 8 GB buffer pool.
Anything else?
Each values table holds a single itemtype, so adding 'itemtype' => $item->getType() (or the known itemtype) to these criteria lets the existing unique index be used. An index on items_id would also work.
- Vorherrschende Sprache
- PHP
- Sterne
- 122
- Forks
- 85
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 20
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pluginsGLPI/fields
-
Slow page loads with many entities: getEntries() checks entities and rights container by container on every requestEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
pluginsGLPI/fields#1347 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[GLPI 11] GenericObject plugin cannot be migrated. Please update it to the latest versionEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 30/100
pluginsGLPI/fields#1015 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in pluginsGLPI/fields
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedEvtl. vergeben @pcvelz hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
OpenMage/magento-lts#5869 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/php-sdk#746 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Map Info Window ButtonsOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
OpenGIS/waymark-wp#82 ·