Add debug timers to instant and range queries.

For now, the query stats are only logged for queries initiated through the UI.
In other cases (rule evaluations), the stats are simply thrown away.