Value lookups by items_id do not use the itemtype index and scan the whole values table
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 75/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- mariadb, php
- Área
- database, performance
Línea de trabajo
Empieza leyendo PluginFieldsField::prepareHtmlFields() y PluginFieldsContainer::updateFieldsValues(), y después localiza las demás llamadas a getFromDBByCrit() mencionadas en la ruta de guardado. Comprueba cómo obtiene cada consulta su tipo de elemento y compara el plan de consulta con la reproducción de EXPLAIN reportada. El trabajo estará terminado cuando estas consultas puedan usar el índice compuesto existente y se evite el recorrido completo de la tabla grande.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PHP
- Estrellas
- 122
- Forks
- 85
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 20
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pluginsGLPI/fields
-
Slow page loads with many entities: getEntries() checks entities and rights container by container on every requestPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
pluginsGLPI/fields#1347 ·
Los mantenedores suelen responder en 1 día
-
[GLPI 11] GenericObject plugin cannot be migrated. Please update it to the latest versionPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
pluginsGLPI/fields#1015 ·
Los mantenedores suelen responder en 1 día
Todos los issues de pluginsGLPI/fields
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedPosiblemente ocupada @pcvelz la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
OpenMage/magento-lts#5869 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
modelcontextprotocol/php-sdk#746 ·
Los mantenedores suelen responder en 1 día
-
Map Info Window ButtonsAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
OpenGIS/waymark-wp#82 ·