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

Seven Principles of a Skilled Designer (1): Font Design

Well, you may be a design guru, or maybe that'...

Detailed tutorial on how to monitor Nginx/Tomcat/MySQL using Zabbix

Table of contents Zabbix monitors Nginx Zabbix mo...

How to change the encoding of MySQL database to utf8mb4

The utf8mb4 encoding is a superset of the utf8 en...

How to run postgreSQL with docker

1. Install Docker. Reference URL: Docker Getting ...

Docker image optimization (from 1.16GB to 22.4MB)

Table of contents The first step of optimization:...

How to install SVN server under Linux

1. Yum installation yum install subversion 2. Con...

Getting Started Tutorial for Beginners⑧: Easily Create an Article Site

In my last post I talked about how to make a web p...

JavaScript to achieve full or reverse selection effect in form

This article shares the specific code of JavaScri...

Use CSS3 to implement button hover flash dynamic special effects code

We have introduced how to create a waterfall layo...

MySQL 8.0.15 installation and configuration graphic tutorial under Win10

This article records the installation and configu...

How to configure Nginx load balancing

Table of contents Nginx load balancing configurat...

Summary of various forms of applying CSS styles in web pages

1. Inline style, placed in <body></body&g...

Detailed explanation of the use of find_in_set() function in MySQL

First, let’s take an example: There is a type fie...