activity query performance improvements part 1