Optimizations for view indexing and querying

These shave a significant amount of time off of Ashvinder’s Test 12.