i only know that query appears continuously in slow_query.log on mysql server.




2011/4/8 Manuel Arostegui Ramirez <manuel.todolinux@gmail.com>


2011/4/8 Chejov Suzdal <agr.suzdal@gmail.com>
hi

and if you add a key `nombre` for table tagente_modulo

select distinct(nombre)
from tagente_modulo
where nombre <> "delete_pending" and id_agente in
(
        select id_agente
        from tagente where id_grupo IN (
                select id_grupo
                from tusuario_perfil
                where id_usuario = "admin"
                and id_perfil IN (
                        select id_perfil
                        from tperfil where agent_view = 1
                )
        )
        OR
        (1 = (
                 SELECT is_admin FROM tusuario WHERE id_user = "admin"
             )
        )
        OR 0 IN (
                select id_grupo
                from tusuario_perfil
                where id_usuario = "admin"
                and id_perfil IN (
                        select id_perfil
                        from tperfil where agent_view = 1
                )
        )
);

# Query_time: 1.178337  Lock_time: 0.000223 Rows_sent: 1080  Rows_examined: 9065

this will change to:

# Query_time: 0.640100  Lock_time: 0.000103 Rows_sent: 1080  Rows_examined: 9065

I'm not seeing any particular issue with that query to be honest as the "nombre" index is not saving you to go thru all the rows in that table (in my case around 12k).
Also, that query is probably cached as it's not different everytime. The one I sent is never the same one as it needs to regenerate the timestamp all the time.

Cheers!
Manu