MySQL limit performance analysis and optimization

MySQL limit performance analysis and optimization

1. Conclusion

Syntax: limit offset, rows

Conclusion: Under the same row conditions, the larger the offset value, the worse the limit statement performance

2. Testing

Execution test: 5750000 data

sql 1 execution time:

SQL 6 execution time:

3. Optimization

Method 1: You can locate the data location based on other index fields such as the primary key ID, and then use limit 0, rows

For example: select * from gift_record_0 where id >= 43611207 limit 1000 0.14 s

Method 2 (based on business needs): For businesses that do not need to display all data, such as only displaying the first 2,000 data items, limit 0, 2000 can meet this requirement.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Solution to data duplication when using limit+order by in MySql paging
  • Why does MySQL paging become slower and slower when using limit?
  • MySQL optimization query_cache_limit parameter description
  • Detailed explanation of the pitfalls of mixing MySQL order by and limit
  • Reasons and optimization solutions for slow MySQL limit paging with large offsets
  • Mysql sorting and paging (order by & limit) and existing pitfalls
  • MySQL uses limit to implement paging example method
  • How to use MySQL limit and solve the problem of large paging
  • A brief discussion on the performance issues of MySQL paging limit
  • Analysis of the Poor Performance Caused by Large Offset of LIMIT in MySQL Query
  • Why does using limit in MySQL affect performance?

<<:  Nginx high concurrency optimization practice

>>:  Echarts Basic Introduction: General Configuration of Bar Chart and Line Chart

Recommend

How to create a MySQL master-slave database using Docker on MacOS

1. Pull the MySQL image Get the latest MySQL imag...

How to build a multi-node Elastic stack cluster on RHEL8 /CentOS8

Elastic stack, commonly known as ELK stack, is a ...

Mysql command line mode access operation mysql database operation

Usage Environment In cmd mode, enter mysql --vers...

Solution to 404 Problem of Tomcat Installation in Docker

Find the containerID of tomcat and enter the toma...

Installing Win10 system on VMware workstation 14 pro

This article introduces how to install the system...

Summary of Docker Data Storage

Before reading this article, I hope you have a ba...

MySQL trigger usage scenarios and method examples

trigger: Trigger usage scenarios and correspondin...

Methods of adaptive web design (good access experience on mobile phones)

1. Add the viewport tag to the HTML header. At th...

Nodejs combined with Socket.IO to realize websocket instant communication

Table of contents Why use websocket Socket.io Ope...

Building a Redis cluster on Docker

Table of contents 1. Pull the image 2. Create a R...

Navicat cannot create function solution sharing

The first time I wrote a MySQL FUNCTION, I kept g...

MySQL 5.7.17 installation and use graphic tutorial

MySQL is a relational database management system ...

Detailed explanation of grep and egrep commands in Linux

rep / egrep Syntax: grep [-cinvABC] 'word'...

Add ico mirror code to html (favicon.ico is placed in the root directory)

Code: Copy code The code is as follows: <!DOCTY...