RANK() performance tweaks