sparse optimizations
Merge pull request #7483 from tanmaykm/tanmaykm

sparse indexing performance improvement.