кстати
14к хостов
160к итемов всего, 39к итемов активных
время выполнения:
39366 rows in set (1.02 sec)
индексы:
14к хостов
160к итемов всего, 39к итемов активных
время выполнения:
39366 rows in set (1.02 sec)
Code:
mysql> explain select i.itemid,i.hostid,h.proxy_hostid,i.type,i.data_type,i.value_type,i.key_,i.snmp_community,i.snmp_oid,i.snmp_port,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.ipmi_sensor,i.delay,i.delay_flex,i.trapper_hosts,i.logtimefmt,i.params,i.status,i.authtype,i.username,i.password,i.publickey,i.privatekey from items i,hosts h where i.hostid=h.hostid and h.status in (0) and i.status in (0,3) and i.itemid between 800800000010001 and 099999999999999999 order by i.itemid; +----+-------------+-------+--------+-------------------------+---------+---------+-----------------+-------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+-------------------------+---------+---------+-----------------+-------+-------------+ | 1 | SIMPLE | i | range | PRIMARY,items_1,items_3 | PRIMARY | 8 | NULL | 92572 | Using where | | 1 | SIMPLE | h | eq_ref | PRIMARY,hosts_2 | PRIMARY | 8 | zabbix.i.hostid | 1 | Using where | +----+-------------+-------+--------+-------------------------+---------+---------+-----------------+-------+-------------+ 2 rows in set (0.00 sec)
Code:
mysql> show index from hosts; +-------+------------+-----------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------+------------+-----------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ | hosts | 0 | PRIMARY | 1 | hostid | A | 14687 | NULL | NULL | | BTREE | | | hosts | 1 | hosts_1 | 1 | host | A | 14687 | NULL | NULL | | BTREE | | | hosts | 1 | hosts_2 | 1 | status | A | 6 | NULL | NULL | | BTREE | | | hosts | 1 | hosts_3 | 1 | proxy_hostid | A | 2 | NULL | NULL | | BTREE | | | hosts | 1 | host_test | 1 | ip | A | 14687 | NULL | NULL | | BTREE | | +-------+------------+-----------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ 5 rows in set (0.00 sec) mysql> show index from items; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | items | 0 | PRIMARY | 1 | itemid | A | 168786 | NULL | NULL | | BTREE | | | items | 0 | items_1 | 1 | hostid | A | 5626 | NULL | NULL | | BTREE | | | items | 0 | items_1 | 2 | key_ | A | 168786 | NULL | NULL | | BTREE | | | items | 1 | items_3 | 1 | status | A | 5 | NULL | NULL | | BTREE | | | items | 1 | items_4 | 1 | templateid | A | 5114 | NULL | NULL | | BTREE | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ 5 rows in set (0.00 sec)
Comment