diff -ru zabbix-2.2.2/src/libs/zbxdbcache/valuecache.c zabbix-2.2.2.limit/src/libs/zbxdbcache/valuecache.c --- zabbix-2.2.2/src/libs/zbxdbcache/valuecache.c 2014-02-12 02:04:36.000000000 -0700 +++ zabbix-2.2.2.limit/src/libs/zbxdbcache/valuecache.c 2014-03-06 15:07:07.555695919 -0700 @@ -428,7 +428,7 @@ zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, " order by clock desc,ns desc"); if (1 == direct) - result = DBselectN(sql, count); + result = DBselectN(sql, count - values->values_num); else result = DBselect("%s", sql); @@ -1252,7 +1252,7 @@ /* Read the item values from database */ if (NULL != ts) { - ret = vc_db_read_values_by_count(itemid, value_type, values, 1, now, ts, 0); + ret = vc_db_read_values_by_count(itemid, value_type, values, 1, now, ts, 1); } else if (0 == count) { @@ -1265,7 +1265,7 @@ if (1 == count) count++; - ret = vc_db_read_values_by_count(itemid, value_type, values, count, now, &ts, 0); + ret = vc_db_read_values_by_count(itemid, value_type, values, count, now, &ts, 1); } if (SUCCEED == ret)