PDA

View Full Version : Query optimization


ad@kbc-clearing.com
14-01-2011, 17:26
Hi All,

We noticed a lot of slow queries:
# Query_time: 5 Lock_time: 0 Rows_sent: 20 Rows_examined: 771705
select value from history_log where itemid=37884 order by id desc limit 20;

The table history_log contains 771705 items for this item.
For many other items, the table also contains 10-thousands of rows.

The query would be A LOT !!! faster if it was written as follows:
select value from history_log where itemid=37884 AND ID > 0 order by id desc limit 20;

In this case, the second index (history_log_2) will be used.

The same applies for other history tables.

We have searched for this query in the source and found something in expression.c and evalfunc.c.

Can the query be changed in the next version ?

fmrapid
14-01-2011, 21:24
Please create a ZBXNEXT request in the support interface.

Flag it on the version you are using.

You can also PM richlv to make sure it gets flagged to the devs for inclusion. ;-) Everyone is interested in a faster Zabbix.

fmrapid

0siris
27-05-2011, 00:57
did this make it to the tracker?

Jason
08-06-2011, 09:17
Is this the same as http://www.zabbix.com/forum/showthread.php?p=84071#post84071?