Optimizations for row_number() window functions