Make queries' locking of indexes more consistent