queryHistory() functionality

Might just be missing/incorrect indexing; see this thread where someone cut their 1.5 minute history query times down dramatically: