create indexes before counting