It takes a lot of time (hours!) to get values with select clock,ns,value from history_uint where itemid=<itemid> and clock<=<timestamp> and clock><timestamp> order by clock desc limit 1 query from a big partitioned DB (e.g. ~40-50GB per each partition). These queries lead to 100% disk IO on the DB server.
A possible solution is to replace the slow SQL query:
with these two: