Preface Usually, a "paging" strategy is adopted for MySQL queries with large amounts of data. However, if the page is turned to a later position, the query will become very slow because MySQL will spend a lot of time scanning the data that needs to be discarded. Basic paging techniques Usually, in order to achieve efficient paging, you need to apply a combined index to the WHERE condition column and the sort column in the query. 1. Field sorting ORDER BY a ORDER BY a,b ORDER BY a, b, c ORDER BY a DESC, b DESC, c DESC 2. Filter and sort WHERE a = const ORDER BY b, c WHERE a = const AND b = const ORDER BY c WHERE a = const ORDER BY b, c WHERE a = const AND b > const ORDER BY b, c 3. The following query cannot use the above index ORDER BY a ASC, b DESC, c DESC // The sorting direction is inconsistent WHERE g = const ORDER BY b, c // Field g is not part of the index WHERE a = const ORDER BY c // Field b is not used WHERE a = const ORDER BY a, d // Field d is not part of the index Solve the problem of page turning for large amounts of data 1. Change the query of LIMIT M,N to LIMIT N Examples: mysql> SELECT <cols> FROM profiles INNER JOIN ( -> SELECT <primary key cols> FROM profiles -> WHERE x.sex='M' ORDER BY rating LIMIT 100000, 10 -> ) AS x USING(<primary key cols>); The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief introduction to the simple use of CentOS7 firewall and open ports
>>: JS realizes the card dealing animation
A few months after entering the industry in 2005, ...
Today, let’s talk about how to start four MySQL d...
1. Use the SELECT clause to query multiple tables...
I. Introduction 1: SSL Certificate My domain name...
The HTML specification document introduces the cr...
In this note, we briefly describe What is the B+T...
In Docker Start all container commands docker sta...
I am currently developing a new app project. This...
Preface I encountered a Mysql deadlock problem so...
Using the CSS3 border-image property, you can set...
Table of contents 1. Direct assignment 2. Shallow...
This article has been included on GitHub https://...
The steps are as follows 1. Create a docker group...
Table of contents SSH protocol SSH Connection pro...
mysql download, install and configure 5.7.20 / 5....