Update: See post #3 for complete patch!
Hi there,
I just found out that most of the database load on our Zabbix server is from queries like this one:
There are quite some log lines in these table, about one million lines for this specific itemid. The query needs about 15 seconds to return one value. It looks like the query is initiated by the function DBget_history_log_value(..) in zbxserver/expression.c .
This method issues two sql queries. One to get the itemid:
and a second one to get the complete value (not limited to 255 characters) from the history_log table:
For me it looks like it's easily possible to add the timestamp to this second query as we already received it from the first query (column lastclock). When we add the timestamp there is no need for the database to sort these one million lines and it should be a very fast operation. Basically just an index lookup.
What dou you think about this? Is there something I missed?
Hi there,
I just found out that most of the database load on our Zabbix server is from queries like this one:
Code:
select value from history_log where itemid=31155 order by id desc limit 1;
This method issues two sql queries. One to get the itemid:
Code:
result = DBselect("select i.itemid,i.value_type from items i,functions f"
" where i.itemid=f.itemid and f.functionid=" ZBX_FS_UI64,
functionid);
Code:
zbx_snprintf(sql, sizeof(sql), "select %s from history_log"
" where itemid=%s order by id desc",
fieldname,
row[0]);
What dou you think about this? Is there something I missed?
Comment