Optimization of MYSQL limit under luna limited php
Also taking 10 pieces of data
select * from yanxue8_visit limit 10000,10
and
select * from yanxue8_visit limit 0,10
are not at the same level of quantity.
There are also many five optimization guidelines for limit on the Internet, which are all translated from the MySQL manual. Although they are correct, they are not practical. Today I found an article about limit optimization, which is very good. Original address: http://www.zhenhua.org/article.asp?id=200
Instead of using limit directly, the article first obtains the ID of the offset and then directly uses the limit size to obtain the data. According to his data, it is obviously better than using limit directly. Here I specifically use data for testing in two situations. (Test environment win2033+p4 dual-core (3GHZ) +4G memory mysql 5.0.19)
1. When the offset is relatively small.
select * from yanxue8_visit limit 10,10
Run multiple times, the time remains between 0.0004-0.0005
Select * From yanxue8_visit Where vid >=(
Select vid From yanxue8_visit Order By vid limit 10,1
) limit 10
After multiple runs, the time remains between 0.0005-0.0006, mainly 0.0006
Conclusion: When the offset offset is small, it is better to use limit directly. This is obviously the reason for the subquery.
2. When the offset is large.
select * from yanxue8_visit limit 10000,10
Run multiple times, the time remains around 0.0187
Select * From yanxue8_visit Where vid >=(
Select vid From yanxue8_visit Order By vid limit 10000,1
) limit 10
run multiple times , the time remains at around 0.0061, only 1/3 of the former. It can be expected that the larger the offset, the better the latter.
The above introduces the optimization of MYSQL limit under luna limited php, including the content of luna limited. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Laravel simplifies HTTP verb handling in incoming requests, streamlining diverse operation management within your applications. The method() and isMethod() methods efficiently identify and validate request types. This feature is crucial for building

The Storage::download method of the Laravel framework provides a concise API for safely handling file downloads while managing abstractions of file storage. Here is an example of using Storage::download() in the example controller:
