rewrite query so it hits index