Fix alert list queries performance
This commit is contained in:
parent
00f94f6732
commit
0c81c9fb59
|
@ -228,12 +228,25 @@ if ($get_agent_alerts_agent_view) {
|
||||||
} else {
|
} else {
|
||||||
$whereAlertSimple .= sprintf(
|
$whereAlertSimple .= sprintf(
|
||||||
' AND id_agent_module IN (
|
' AND id_agent_module IN (
|
||||||
SELECT tam.id_agente_modulo
|
SELECT tam.id_agente_modulo
|
||||||
FROM tagente_modulo tam
|
FROM tagente_modulo tam
|
||||||
WHERE tam.id_agente IN (SELECT ta.id_agente
|
WHERE tam.id_agente IN (
|
||||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
|
SELECT
|
||||||
ta.id_agente = tasg.id_agent
|
ta.id_agente
|
||||||
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
|
FROM
|
||||||
|
tagente ta
|
||||||
|
WHERE
|
||||||
|
ta.id_grupo IN (%s)
|
||||||
|
)
|
||||||
|
OR tam.id_agente IN (
|
||||||
|
SELECT
|
||||||
|
DISTINCT(tasg.id_agent)
|
||||||
|
FROM
|
||||||
|
tagent_secondary_group tasg
|
||||||
|
WHERE
|
||||||
|
tasg.id_group IN (%s)
|
||||||
|
)
|
||||||
|
) ',
|
||||||
implode(',', $id_groups),
|
implode(',', $id_groups),
|
||||||
implode(',', $id_groups)
|
implode(',', $id_groups)
|
||||||
);
|
);
|
||||||
|
@ -833,12 +846,20 @@ if ($get_agent_alerts_datatable === true) {
|
||||||
} else {
|
} else {
|
||||||
$whereAlertSimple .= sprintf(
|
$whereAlertSimple .= sprintf(
|
||||||
' AND id_agent_module IN (
|
' AND id_agent_module IN (
|
||||||
SELECT tam.id_agente_modulo
|
SELECT tam.id_agente_modulo
|
||||||
FROM tagente_modulo tam
|
FROM tagente_modulo tam
|
||||||
WHERE tam.id_agente IN (SELECT ta.id_agente
|
WHERE
|
||||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
|
tam.id_agente IN (
|
||||||
ta.id_agente = tasg.id_agent
|
SELECT ta.id_agente
|
||||||
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
|
FROM tagente ta
|
||||||
|
WHERE ta.id_grupo IN (%s)
|
||||||
|
)
|
||||||
|
OR tam.id_agente IN (
|
||||||
|
SELECT DISTINCT(tasg.id_agent)
|
||||||
|
FROM tagent_secondary_group tasg
|
||||||
|
WHERE tasg.id_group IN (%s)
|
||||||
|
)
|
||||||
|
) ',
|
||||||
implode(',', $id_groups),
|
implode(',', $id_groups),
|
||||||
implode(',', $id_groups)
|
implode(',', $id_groups)
|
||||||
);
|
);
|
||||||
|
|
|
@ -2191,15 +2191,19 @@ function get_group_alerts(
|
||||||
} else {
|
} else {
|
||||||
$subQuery = 'SELECT id_agente_modulo
|
$subQuery = 'SELECT id_agente_modulo
|
||||||
FROM tagente_modulo tam
|
FROM tagente_modulo tam
|
||||||
WHERE delete_pending = 0 AND tam.disabled = 0
|
WHERE delete_pending = 0
|
||||||
AND id_agente IN (SELECT id_agente
|
AND tam.disabled = 0
|
||||||
FROM tagente ta
|
AND id_agente IN (
|
||||||
LEFT JOIN tagent_secondary_group tasg
|
SELECT ta.id_agente
|
||||||
ON ta.id_agente = tasg.id_agent
|
FROM tagente ta
|
||||||
WHERE ta.disabled = 0
|
WHERE ta.disabled = 0
|
||||||
AND
|
AND ta.id_grupo IN ('.implode(',', $id_group).')
|
||||||
id_grupo IN ('.implode(',', $id_group).')
|
)
|
||||||
OR id_group IN ('.implode(',', $id_group).'))';
|
OR tam.id_agente IN (
|
||||||
|
SELECT DISTINCT(tasg.id_agent)
|
||||||
|
FROM tagent_secondary_group tasg
|
||||||
|
WHERE tasg.id_group IN ('.implode(',', $id_group).')
|
||||||
|
)';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$subQuery = 'SELECT id_agente_modulo
|
$subQuery = 'SELECT id_agente_modulo
|
||||||
|
|
Loading…
Reference in New Issue