V 1.6.1
some field in sql query hasn`t index, you can see it if include log-queries-not-using-indexes option in my.cnf file.
I create some index for faster work mysql.
I think it`s realy good.
CREATE INDEX graphid ON graphs_items ( graphid );
CREATE INDEX sortorder ON graphs_items ( sortorder );
CREATE INDEX screenxy ON screens_items ( screenid,x,y );
CREATE INDEX userid ON users_groups ( userid );
CREATE INDEX usrgrpid ON users_groups ( usrgrpid );
CREATE INDEX eventid ON escalations ( eventid );
CREATE INDEX status ON escalations ( status );
CREATE INDEX nextcheck ON escalations ( nextcheck );
CREATE INDEX nodetype ON nodes ( nodetype );
CREATE INDEX hostid ON hosts_groups ( hostid );
CREATE INDEX groupid ON hosts_groups ( groupid );
CREATE INDEX id ON rights ( id );
CREATE INDEX name ON nodes ( name );
==========================================
Why?
==========================================
#SELECT gi.* FROM graphs_items gi WHERE gi.graphid=464 ORDER BY gi.sortorder, gi.itemid DESC;
CREATE INDEX graphid ON graphs_items ( graphid );
CREATE INDEX sortorder ON graphs_items ( sortorder );
#select * from screens_items where screenid=6 and x=5 and y=4;
CREATE INDEX screenxy ON screens_items ( screenid,x,y );
#SELECT MAX(g.gui_access) as gui_access
#FROM usrgrp g, users_groups ug
#WHERE ug.userid=2 AND g.usrgrpid=ug.usrgrpid;
CREATE INDEX userid ON users_groups ( userid );
CREATE INDEX usrgrpid ON users_groups ( usrgrpid );
#SELECT e.escalationid,e.actionid,e.r_eventid,e.esc_step,e .status, #ev.eventid,ev.source,ev.object,ev.objectid,ev.clo ck,ev.value,ev.acknowledged
#FORM escalations e,events ev
#WHERE e.eventid=ev.eventid and e.status in (0,1) and e.nextcheck<=1230197156 and escalationid between 00 and 09;
CREATE INDEX eventid ON escalations ( eventid );
CREATE INDEX status ON escalations ( status );
CREATE INDEX nextcheck ON escalations ( nextcheck );
#SELECT * FROM nodes WHERE nodetype=1 order by nodeid;
CREATE INDEX nodetype ON nodes ( nodetype );
#SELECT DISTINCT n.nodeid, n.name as node_name, h.hostid, h.host, min(r.permission) as permission, ug.userid
#FROM hosts h
#LEFT JOIN hosts_groups hg ON hg.hostid=h.hostid
#LEFT JOIN groups g ON g.groupid=hg.groupid
#LEFT JOIN rights r ON r.id=g.groupid
#LEFT JOIN users_groups ug ON ug.usrgrpid=r.groupid and ug.userid=2
#LEFT JOIN nodes n ON (h.hostid div 100000000000000)=n.nodeid
#WHERE (h.hostid div 100000000000000) in (0)
#GROUP BY h.hostid,n.nodeid,n.name,h.host,ug.userid
#ORDER BY n.name,n.nodeid, h.host, permission, ug.userid;
#hosts_groups
#hostid,groupid - may be not need? ( KEY `hosts_groups_groups_1` (`hostid`,`groupid`))
CREATE INDEX hostid ON hosts_groups ( hostid );
CREATE INDEX groupid ON hosts_groups ( groupid );
# rights
# filed: id
CREATE INDEX id ON rights ( id );
#nodes
# filed: name
CREATE INDEX name ON nodes ( name );
some field in sql query hasn`t index, you can see it if include log-queries-not-using-indexes option in my.cnf file.
I create some index for faster work mysql.
I think it`s realy good.
CREATE INDEX graphid ON graphs_items ( graphid );
CREATE INDEX sortorder ON graphs_items ( sortorder );
CREATE INDEX screenxy ON screens_items ( screenid,x,y );
CREATE INDEX userid ON users_groups ( userid );
CREATE INDEX usrgrpid ON users_groups ( usrgrpid );
CREATE INDEX eventid ON escalations ( eventid );
CREATE INDEX status ON escalations ( status );
CREATE INDEX nextcheck ON escalations ( nextcheck );
CREATE INDEX nodetype ON nodes ( nodetype );
CREATE INDEX hostid ON hosts_groups ( hostid );
CREATE INDEX groupid ON hosts_groups ( groupid );
CREATE INDEX id ON rights ( id );
CREATE INDEX name ON nodes ( name );
==========================================
Why?
==========================================
#SELECT gi.* FROM graphs_items gi WHERE gi.graphid=464 ORDER BY gi.sortorder, gi.itemid DESC;
CREATE INDEX graphid ON graphs_items ( graphid );
CREATE INDEX sortorder ON graphs_items ( sortorder );
#select * from screens_items where screenid=6 and x=5 and y=4;
CREATE INDEX screenxy ON screens_items ( screenid,x,y );
#SELECT MAX(g.gui_access) as gui_access
#FROM usrgrp g, users_groups ug
#WHERE ug.userid=2 AND g.usrgrpid=ug.usrgrpid;
CREATE INDEX userid ON users_groups ( userid );
CREATE INDEX usrgrpid ON users_groups ( usrgrpid );
#SELECT e.escalationid,e.actionid,e.r_eventid,e.esc_step,e .status, #ev.eventid,ev.source,ev.object,ev.objectid,ev.clo ck,ev.value,ev.acknowledged
#FORM escalations e,events ev
#WHERE e.eventid=ev.eventid and e.status in (0,1) and e.nextcheck<=1230197156 and escalationid between 00 and 09;
CREATE INDEX eventid ON escalations ( eventid );
CREATE INDEX status ON escalations ( status );
CREATE INDEX nextcheck ON escalations ( nextcheck );
#SELECT * FROM nodes WHERE nodetype=1 order by nodeid;
CREATE INDEX nodetype ON nodes ( nodetype );
#SELECT DISTINCT n.nodeid, n.name as node_name, h.hostid, h.host, min(r.permission) as permission, ug.userid
#FROM hosts h
#LEFT JOIN hosts_groups hg ON hg.hostid=h.hostid
#LEFT JOIN groups g ON g.groupid=hg.groupid
#LEFT JOIN rights r ON r.id=g.groupid
#LEFT JOIN users_groups ug ON ug.usrgrpid=r.groupid and ug.userid=2
#LEFT JOIN nodes n ON (h.hostid div 100000000000000)=n.nodeid
#WHERE (h.hostid div 100000000000000) in (0)
#GROUP BY h.hostid,n.nodeid,n.name,h.host,ug.userid
#ORDER BY n.name,n.nodeid, h.host, permission, ug.userid;
#hosts_groups
#hostid,groupid - may be not need? ( KEY `hosts_groups_groups_1` (`hostid`,`groupid`))
CREATE INDEX hostid ON hosts_groups ( hostid );
CREATE INDEX groupid ON hosts_groups ( groupid );
# rights
# filed: id
CREATE INDEX id ON rights ( id );
#nodes
# filed: name
CREATE INDEX name ON nodes ( name );
)
Comment