Tag

ORDER BY

1 views collected around this technical thread.

Aikesheng Open Source Community
Aikesheng Open Source Community
Mar 3, 2025 · Databases

MySQL 5.7 → 8.0 Upgrade: Performance Degradation Analysis and Optimization

After upgrading a client from MySQL 5.7 to 8.0, query performance slowed dramatically due to changes in ORDER BY handling, and the article analyzes the root cause, presents verification tests, and recommends adding indexes to restore millisecond‑level response times.

IndexingORDER BYSQL Optimization
0 likes · 7 min read
MySQL 5.7 → 8.0 Upgrade: Performance Degradation Analysis and Optimization
JD Retail Technology
JD Retail Technology
Oct 20, 2023 · Databases

Understanding Pagination Issues with ORDER BY and LIMIT in MySQL

This article examines why combining ORDER BY with LIMIT in MySQL pagination can produce duplicate rows on subsequent pages, analyzes the optimizer’s priority‑queue behavior introduced in version 5.6, and presents practical solutions such as using unique sort keys, adding ID ordering, and understanding deep‑pagination limitations.

DatabaseORDER BYSQL
0 likes · 8 min read
Understanding Pagination Issues with ORDER BY and LIMIT in MySQL
Architecture Digest
Architecture Digest
Feb 22, 2023 · Databases

Understanding the Execution Order of SQL Queries

This article explains the logical execution sequence of a typical SQL query, detailing each phase from FROM/JOIN/WHERE through GROUP BY, HAVING, SELECT, ORDER BY, and LIMIT, and illustrating the process with diagrams and code examples.

DatabaseFrom Join WhereGROUP BY
0 likes · 8 min read
Understanding the Execution Order of SQL Queries
Java Architect Essentials
Java Architect Essentials
Feb 19, 2023 · Databases

Understanding the Execution Order of SQL Queries

This article explains the step‑by‑step execution order of a standard SQL query, covering FROM/JOIN, WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY and LIMIT, and provides illustrative code snippets and diagrams to clarify each stage.

FROMGROUP BYHAVING
0 likes · 5 min read
Understanding the Execution Order of SQL Queries
Laravel Tech Community
Laravel Tech Community
Feb 14, 2022 · Databases

Why LIMIT with ORDER BY Can Produce Duplicate Pages in MySQL and How to Resolve It

The article explains why using LIMIT together with ORDER BY in MySQL 5.6 can cause duplicate records on subsequent pages, analyzes the priority‑queue optimization that makes the sort unstable, and offers practical solutions such as indexing, proper pagination logic, and query adjustments.

ORDER BYPriority Queuedatabase indexing
0 likes · 8 min read
Why LIMIT with ORDER BY Can Produce Duplicate Pages in MySQL and How to Resolve It
Architecture & Thinking
Architecture & Thinking
Dec 22, 2021 · Databases

Mastering SQL ORDER BY and LIMIT: Sorting, Pagination, and Best Practices

Learn how to effectively sort query results using ORDER BY, apply ASC/DESC rules, combine multiple fields, use aliases, integrate functions, and limit result sets with LIMIT for pagination, while avoiding common pitfalls such as duplicate sorting values and expression misuse in MySQL.

ORDER BYSQLlimit
0 likes · 16 min read
Mastering SQL ORDER BY and LIMIT: Sorting, Pagination, and Best Practices
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Aug 5, 2021 · Databases

Understanding and Optimizing ORDER BY in MySQL

This article explains the internal execution process of MySQL's ORDER BY, compares full‑field and rowid sorting, shows how indexes, sort_buffer size and max_length_for_sort_data affect performance, and provides practical optimization techniques such as composite and covering indexes.

Covering IndexIndexORDER BY
0 likes · 13 min read
Understanding and Optimizing ORDER BY in MySQL
Laravel Tech Community
Laravel Tech Community
Jun 28, 2021 · Databases

Understanding and Optimizing MySQL ORDER BY Execution

This article explains how MySQL processes ORDER BY clauses, illustrates the execution steps with a full‑field index, discusses the impact of sort_buffer and max_length_for_sort_data, and shows how adding composite and covering indexes can eliminate filesort and improve query performance.

Index OptimizationORDER BYSQL performance
0 likes · 6 min read
Understanding and Optimizing MySQL ORDER BY Execution
Top Architect
Top Architect
Apr 3, 2021 · Databases

Understanding and Solving Duplicate Records When Using ORDER BY with LIMIT in MySQL

This article explains why MySQL 5.6 may return duplicate rows on the second page when using ORDER BY with LIMIT, analyzes the optimizer’s priority‑queue behavior, and provides practical solutions such as indexing, proper pagination understanding, and handling of sorting edge cases.

DatabaseIndexingORDER BY
0 likes · 7 min read
Understanding and Solving Duplicate Records When Using ORDER BY with LIMIT in MySQL
Architect's Tech Stack
Architect's Tech Stack
Feb 6, 2021 · Databases

Understanding MySQL ORDER BY with LIMIT Pagination Issues and Their Fixes

This article explains why using ORDER BY with LIMIT for pagination in MySQL can yield inconsistent results when the ordering column contains duplicate values, describes MySQL's limit optimization behavior, and provides a reliable solution by adding a secondary unique sort key.

DatabaseORDER BYQuery Optimization
0 likes · 5 min read
Understanding MySQL ORDER BY with LIMIT Pagination Issues and Their Fixes
Aikesheng Open Source Community
Aikesheng Open Source Community
Nov 26, 2020 · Databases

Understanding Index Selectivity, Filtering, and Order‑By Optimization in MySQL

This article explains common misconceptions about index selectivity and filtering, demonstrates how composite indexes can avoid slow queries, and shows why order‑by may still trigger filesort, providing practical tips and SQL examples for better MySQL index design.

Database PerformanceIndex OptimizationORDER BY
0 likes · 7 min read
Understanding Index Selectivity, Filtering, and Order‑By Optimization in MySQL
Tencent Cloud Developer
Tencent Cloud Developer
May 5, 2019 · Databases

Handling ORDER BY When Index Order Differs and Using Descending Indexes in MySQL

MySQL can avoid a filesort for ORDER BY clauses that match an index’s direction by scanning the index forward or backward, and MySQL 8.0’s descending indexes let mixed‑direction sorts be satisfied similarly; for older versions you can emulate this by retrieving rows in index order and reversing groups in the application.

DatabaseDescending IndexIndexing
0 likes · 9 min read
Handling ORDER BY When Index Order Differs and Using Descending Indexes in MySQL
Vipshop Quality Engineering
Vipshop Quality Engineering
Sep 18, 2017 · Databases

Why a Simple ORDER BY Caused a 20‑Second MySQL Slow Query and How to Fix It

A recent order‑fulfillment outage was traced to a MySQL query that used the primary‑key index because an ORDER BY id ASC LIMIT 350 forced a full scan, but tweaking the ORDER BY or removing it reduced execution time from 20 seconds to under one second.

Index OptimizationORDER BYPerformance Tuning
0 likes · 6 min read
Why a Simple ORDER BY Caused a 20‑Second MySQL Slow Query and How to Fix It