Our training ensures your team can effectively manage and analyze large volumes of data, providing valuable insights and driving business growth.

Modern web pages uses pagination to show query results. Using this method also optimizes query performance if the query returns large rows.Most of time index creates for the columns in where clause of sql queries to optimize sql queries. In addition to this you may use indexes for pagination and optimizing orders.


For example a pagination query likes this


select *
from product_orders
order by order_date
limit 100


product_orders tables have 5000000 records. Without index mysql engine must read all table rows sort by order_date then limit 100 records which is very inefficient shown in execution plan in MYSQL db. cost is 535090

Modern web pages uses pagination to show query results. Using this method also optimizes query performance if the query returns large rows.Most of time index creates for the columns in where clause of sql queries to optimize sql queries. In addition to this you may use indexes for pagination and optimizing orders.


For example a pagination query likes this


select *
from product_orders
order by order_date
limit 100


product_orders tables have 5000000 records. Without index mysql engine must read all table rows sort by order_date then limit 100 records which is very inefficient shown in execution plan in MYSQL db. cost is 535090

Execution Plan Without Index

Execution Plan Without Index

After creating index on order_date and looking execution plan cost is 1.1 which is 500000 times less then original query plan.

After creating index on order_date and looking execution plan cost is 1.1 which is 500000 times less then original query plan.

Execution Plan With Index

Execution Plan With Index

© 2024 BiSoft. All rights reserved.

© 2024 BiSoft. All rights reserved.

Blog

Pagination & Order by Optimization in Databases


Pagination & Order by Optimization in Databases

Blog

Pagination & Order by Optimization in Databases

© 2024 BiSoft. All rights reserved.

© 2024 BiSoft. All rights reserved.