It actually optimizes, because when it sorts its queries, it takes the pagination integer value and brings the values on page x, for example, it can show values between 5, 50 and 60, which means that instead of 1 million records, it only pulls 10 and performs pagination