KHRES-309 #comment continue to optimize sql queries and add indexes, simplifying term count query