The object which has the history tracking enabled in my organization is being modified 3 to 4 times a day, so we end up with 112 history records per month.
I have a page that queries the history and compares the values in the dates, and the page times out when executing the code because the query takes too long to run. If I run the query on the console, it takes too long too (here "too long" means, sometimes, some minutes). The interesting thing is that when the server can get me the results, the query becomes faster.
It seems that the records are not in memory, and then Salesforce gets the history on memory to make it faster to query the records (and that's why it is faster sometime after).
Has anyone experienced this situation before? If so, how did you solve this issue?