Only query indexes if needed.