Why does OFFSET pagination slow down, and what can replace it?
A service returns a list of orders in pages. To fetch a page far into the list, it runs ORDER BY created_at DESC LIMIT 20 OFFSET 100000. Why does the query get slower as users move to later pages? What happens if orders are inserted or deleted between page requests? How would you implement pagination differently?
ExplainEXPLAIN and optimizationMiddleBackendData Engineer