Tagged articles
LIMIT
77 articles · Page 1 of 1
The article explains why OFFSET/LIMIT pagination causes full table scans and linear performance degradation with large offsets, demonstrates a 100k-row benchmark where cursor-based pagination using primary keys runs in 0.01s versus 12.80s for OFFSET, and recommends keyset pagination for scalable systems while noting limitations for tables without unique sequential columns.
Keyset PaginationLIMITOFFSET
0 likes · 7 min read

A MySQL query that should return a single row became 50 times slower after adding LIMIT 1 because the optimizer chose a suboptimal index, and the article explains the root cause and three practical ways to resolve the issue.
LIMITSQLindexes
0 likes · 7 min read

Adding a LIMIT 1 clause to a MySQL query that fetches the latest order for a user can unexpectedly trigger a full‑table scan, slowing execution by up to 50 times; this article explains the optimizer’s mis‑choice, shows EXPLAIN analysis, and offers three practical remedies.
EXPLAINIndexLIMIT
0 likes · 8 min read

This tutorial demonstrates how MySQL LIMIT pagination performs on tables with millions of rows, measures query times for various offsets and batch sizes, and presents practical optimization techniques such as sub‑queries, ID‑range filtering, and column selection to improve speed.
LIMITOptimizationPagination
0 likes · 9 min read

The article shows how common MySQL performance pitfalls—such as large LIMIT offsets, implicit type conversions, sub‑query‑based updates or deletes, mixed ORDER BY, EXISTS clauses, and misplaced predicates—can be rewritten into index‑friendly forms using filters, joins, early limits, UNION ALL, and CTEs to achieve execution times that drop from seconds to milliseconds.
LIMITQuery PerformanceSQL Optimization
0 likes · 14 min read

This article examines frequent MySQL performance problems such as inefficient LIMIT pagination, implicit type conversion, sub‑query updates, mixed sorting, misuse of EXISTS, condition push‑down limitations, early result narrowing, intermediate result push‑down, and demonstrates how rewriting queries with JOINs, derived tables, and WITH clauses can dramatically improve execution speed.
IndexLIMITSQL Optimization
0 likes · 11 min read

The article explains how using a large OFFSET with MySQL LIMIT forces the engine to scan and sort hundreds of thousands of index and data pages, then presents three concrete optimizations—covering index scans, subqueries, and partitioned tables—to dramatically reduce the work.
B+ TreeCovering IndexLIMIT
0 likes · 9 min read

Learn eight practical MySQL optimization strategies—including smarter LIMIT usage, avoiding implicit type conversion, rewriting subqueries with JOINs, handling mixed sorting, eliminating costly EXISTS clauses, pushing conditions, pre‑filtering data, and leveraging intermediate result sets—to dramatically reduce query execution time from seconds to milliseconds.
IndexingLIMITQuery Optimization
0 likes · 15 min read

This article explains how the LIMIT clause can cause massive I/O and CPU overhead in MySQL queries, analyzes the underlying B+‑tree index structure and execution plans, and presents practical optimization techniques such as covering indexes, sub‑queries, and partitioning.
LIMITSQLmysql
0 likes · 9 min read

This article explains why using OFFSET and LIMIT for pagination becomes inefficient on large tables, illustrates the performance impact with examples, and proposes a cursor‑based pagination alternative that leverages indexed primary keys to achieve faster, scalable queries.
CursorLIMITOFFSET
0 likes · 8 min read

This article explains why using OFFSET and LIMIT for pagination on large tables leads to costly full‑table scans and poor performance, and introduces keyset (cursor) pagination as a faster, index‑driven alternative while discussing its requirements and trade‑offs.
CursorLIMITOFFSET
0 likes · 5 min read

This article explains why MySQL's LIMIT offset,size becomes slower as the offset grows, compares it with LIMIT size, details the internal execution using primary and secondary indexes, discusses deep pagination issues, and presents practical optimization techniques to improve query performance.
Deep PaginationLIMITPagination
0 likes · 14 min read

This article reproduces MySQL's official LIMIT‑optimization example, shows how adding rows changes the ORDER BY + LIMIT result, explains the hidden priority‑queue mechanism revealed by optimizer_trace, and derives the exact row‑count threshold where the behavior switches.
LIMITheap sortmysql
0 likes · 18 min read

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.
LIMITORDER BYPagination
0 likes · 8 min read

This article walks through creating a 10‑million‑row MySQL table, measuring pagination performance with LIMIT, and applying practical optimizations—such as index‑based subqueries, ID‑range queries, and column selection—to dramatically reduce query latency on large data sets.
LIMITLarge DatasetOptimization
0 likes · 10 min read

The article explains the performance drawbacks of using OFFSET and LIMIT for pagination on large tables, illustrates the issue with full‑table scans, and presents a more efficient cursor‑based approach that leverages indexed primary keys to retrieve pages quickly.
CursorLIMITOFFSET
0 likes · 5 min read

The article explains why adding a LIMIT clause to MySQL DELETE statements is a recommended habit, detailing performance gains, reduced locking, safer error handling, and practical execution strategies for large‑scale deletions.
DELETELIMITSQL
0 likes · 6 min read

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.
From Join WhereHAVINGLIMIT
0 likes · 8 min read

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.
FROMHAVINGLIMIT
0 likes · 5 min read

This article presents nine practical MySQL optimization methods—including smarter LIMIT usage, avoiding implicit type conversion, rewriting subqueries as joins, handling mixed sorting, replacing EXISTS with joins, pushing conditions into subqueries, early range reduction, and using CTEs—to dramatically improve query execution time across common scenarios.
CTEDatabase IndexesLIMIT
0 likes · 14 min read

This article presents a series of practical MySQL performance‑tuning methods—including smarter LIMIT usage, handling implicit type conversion, rewriting UPDATE/DELETE with JOIN, mixed‑order optimization, EXISTS replacement, condition push‑down, early result filtering, and CTE usage—to dramatically reduce query execution time across common scenarios.
CTELIMITQuery Performance
0 likes · 13 min read

This article explains how MySQL 8.0's prefer_ordering_index optimizer switch can be toggled to improve LIMIT queries that involve ORDER BY and GROUP BY, demonstrates the effect with test data, and shows why manual parameter control can yield better execution plans.
IndexingLIMITOptimizer
0 likes · 6 min read

This article breaks down the step-by-step SQL execution sequence—from FROM and JOIN through WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, to LIMIT—illustrating each phase with examples, diagrams, and code snippets to help you understand how queries are processed and optimized.
FROMHAVINGLIMIT
0 likes · 7 min read

This article explains how MySQL processes LIMIT with an offset, why large offsets cause slower queries and deep‑pagination problems, and presents practical optimization techniques such as id‑based pagination, sub‑queries, and index‑aware strategies to improve performance.
Deep PaginationLIMITmysql
0 likes · 14 min read

The article explains the performance problems of using OFFSET and LIMIT for large‑scale database pagination, demonstrates their inefficiency with full‑table scans, and presents a faster cursor‑based alternative that relies on storing the last primary key and using LIMIT instead of OFFSET.
CursorLIMITOFFSET
0 likes · 8 min read

The article explains why a MySQL query with a large LIMIT offset becomes extremely slow, demonstrates the underlying I/O behavior, and shows how rewriting the query with a sub‑query that fetches primary keys first can cut execution time from seconds to milliseconds while also reducing buffer‑pool pollution.
Buffer PoolInnoDBLIMIT
0 likes · 9 min read

A recent poll revealed that MySQL with the InnoDB engine can support up to four billion tables, a limit dictated by the underlying file system rather than MySQL itself, and the official documentation confirms this massive capacity.
InnoDBLIMITdatabases
0 likes · 2 min read

Using a large OFFSET in MySQL's LIMIT clause forces the server to scan hundreds of thousands of index and data pages, causing excessive random I/O, whereas rewriting the query with a sub‑select and join reduces page accesses dramatically, as demonstrated through buffer‑pool measurements.
Buffer PoolIndexLIMIT
0 likes · 8 min read

The article demonstrates that MySQL queries using LIMIT with a large offset cause heavy random I/O by scanning many rows, and shows how rewriting the query with a sub‑query that selects only primary keys dramatically reduces execution time from seconds to milliseconds.
Buffer PoolLIMITQuery Optimization
0 likes · 8 min read

This article analyzes why a MySQL query with a large LIMIT offset can take seconds to run, demonstrates the underlying index and buffer‑pool behavior, and shows how rewriting the query with a sub‑select of primary keys reduces execution time from over 16 seconds to under half a second.
Buffer PoolIndexLIMIT
0 likes · 9 min read

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.
Database IndexingLIMITORDER BY
0 likes · 8 min read

The article explains why using COUNT(*) to test for record existence is inefficient and demonstrates how replacing it with SELECT 1 … LIMIT 1 in SQL and a corresponding Java existence check can significantly improve database query performance.
COUNTLIMITOptimization
0 likes · 3 min read

The article explains the true execution order of SQL queries, detailing each step from FROM and JOIN through WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, and LIMIT, and illustrates the concepts with examples and code snippets.
FROMHAVINGLIMIT
0 likes · 6 min read

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.
LIMITORDER BYPagination
0 likes · 16 min read

Using LIMIT with a large offset in MySQL can cause severe performance degradation due to excessive random I/O, but by rewriting the query to first fetch primary keys in a subquery and then joining, execution time can drop from seconds to milliseconds, as demonstrated with real data.
Buffer PoolInnoDBLIMIT
0 likes · 10 min read

In a production environment, a pagination export feature caused duplicate and missing records due to MySQL’s nondeterministic ordering when multiple rows share the same ORDER BY value, and the article explains the root cause, official documentation, and a reliable solution using additional sorting columns.
LIMITORDER BYPagination
0 likes · 10 min read

This article explains Cobar’s sharding middleware and presents an optimization technique for handling ORDER BY and LIMIT queries across multiple databases, detailing the original approach, its inefficiencies with deep pagination, the step‑by‑step improved algorithm, performance analysis, limitations, and practical applicability.
CobarLIMITORDER BY
0 likes · 8 min read

The article explains why using LIMIT with a large OFFSET in MySQL causes severe performance degradation, demonstrates the issue with a 5‑million‑row table, and shows how rewriting the query as a join dramatically reduces I/O and execution time while also discussing buffer‑pool effects.
Buffer PoolIndexLIMIT
0 likes · 8 min read

The article demonstrates how a large OFFSET in a MySQL LIMIT query forces MySQL to scan millions of index rows and data pages, causing severe slowdown, and shows that rewriting the query with an inner‑join sub‑select dramatically reduces I/O and buffer‑pool usage, confirming the performance difference through experiments.
Buffer PoolInnoDBLIMIT
0 likes · 8 min read

This article explains why using a large OFFSET with MySQL LIMIT can cause severe performance degradation, demonstrates the problem with a real‑world 9.5 million‑row table, and shows how rewriting the query with a sub‑query that selects only primary keys can cut execution time from seconds to milliseconds.
InnoDBLIMITSQL Optimization
0 likes · 8 min read

Java 17 introduces a SIZED characteristic for streams that keeps skip() and limit() effective without traversing elements, altering the behavior of operations like peek() and requiring developers to adjust their code accordingly.
JavaLIMITSIZED
0 likes · 2 min read

Using MySQL's ORDER BY with LIMIT can yield an unexpected row order because duplicate values in the sorting column cause nondeterministic results; adding a unique secondary column like id stabilizes the order, and the official documentation explains how LIMIT influences query planning and optimization.
LIMITORDER BYQuery Planning
0 likes · 6 min read


ITPUBAug 19, 2021 · Databases
When using MySQL pagination with LIMIT together with ORDER BY, the second page can unexpectedly contain rows from the first page because MySQL 5.6's priority‑queue optimization performs an unstable heap sort, causing nondeterministic ordering for equal values and leading to duplicate results.
LIMITORDER BYPagination
0 likes · 7 min read


ITPUBAug 13, 2021 · Databases
When a MySQL query uses LIMIT with a large offset on a table of millions of rows, the database must scan hundreds of thousands of index entries and corresponding clustered rows, causing massive random I/O; rewriting the query with a sub‑query join reduces I/O dramatically, cutting execution time from over a minute to under a second while also preventing buffer‑pool pollution.
Buffer PoolInnoDBLIMIT
0 likes · 9 min read

This article analyzes six MySQL pagination techniques, presents benchmark results showing how query time grows with offset, and offers practical index‑based optimizations—including covering indexes, subqueries, and composite index design—to make LIMIT pagination fast even on very large tables.
IndexLIMITPagination
0 likes · 12 min read

This article examines the performance drawbacks of MySQL's LIMIT pagination on large tables, presents six practical query methods—including direct LIMIT, primary‑key indexing, index‑based ordering, prepared statements, covering indexes, and sub‑query/join techniques—provides extensive benchmark results, and offers concrete indexing recommendations to achieve fast, stable pagination even with millions of rows.
IndexingLIMITLarge Data
0 likes · 12 min read

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.
IndexingLIMITORDER BY
0 likes · 7 min read

This article explains why combining LIMIT with ORDER BY in MySQL can cause duplicate rows on subsequent pages, analyzes the priority‑queue optimization that makes sorting unstable, and offers practical solutions such as indexing, stable ORDER BY clauses, and a deeper understanding of pagination behavior.
Database PerformanceLIMITORDER BY
0 likes · 7 min read

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.
LIMITORDER BYPagination
0 likes · 5 min read

This article explains the difference between logical and physical pagination, demonstrates how MySQL's LIMIT clause works, compares two query methods on a large MEMORY table, analyzes their performance with indexes and EXPLAIN, and provides practical pagination examples and Java code for efficient data retrieval.
LIMITPaginationSQL
0 likes · 7 min read

The article explains why appending LIMIT to MySQL DELETE statements improves performance, reduces lock contention, and safeguards data by limiting rows affected, provides syntax details, compares deletion strategies for removing large numbers of rows, and offers practical recommendations for safe and efficient data removal.
DELETEData SafetyDatabase Performance
0 likes · 8 min read

When you combine ORDER BY with LIMIT in MySQL, the result set may appear in a different order than expected, especially if the ordered column contains duplicate values, and understanding the optimizer's behavior and adding deterministic columns can resolve this issue.
LIMITORDER BYQuery Optimization
0 likes · 6 min read

The article explains that using LIMIT with DELETE in MySQL improves safety, reduces lock time, prevents long‑running transactions, and enhances performance, and it provides syntax, examples, and expert opinions to illustrate the benefits of this habit.
DELETEDatabase PerformanceLIMIT
0 likes · 7 min read

This article explains why adding a LIMIT clause to MySQL DELETE statements is a good habit, compares it with TRUNCATE, shows the correct syntax, outlines performance and safety advantages, and discusses practical strategies for deleting large numbers of rows.
DELETELIMITSQL
0 likes · 7 min read

This article explains why appending a LIMIT clause to MySQL DELETE statements improves safety, reduces lock time, and boosts performance, while comparing three deletion strategies and recommending the most efficient approach for large‑scale data removal.
DELETELIMITSQL Best Practices
0 likes · 8 min read

The article explains the performance problems of using OFFSET and LIMIT for database pagination on large tables, demonstrates their inefficiency with real‑world examples, and presents cursor‑based pagination as a high‑performance alternative that leverages indexed primary keys.
CursorLIMITOFFSET
0 likes · 6 min read

This article examines various MySQL pagination strategies—including simple LIMIT clauses, sub‑query optimizations, ID‑range queries, and temporary‑table methods—by testing them on a table with millions of rows and presenting detailed timing results that reveal significant speed improvements.
LIMITPaginationQuery Optimization
0 likes · 9 min read

The article demonstrates how moving the LIMIT‑OFFSET condition into a subquery that selects only primary‑key IDs and then joining back to the main table can cut execution time from over 16 seconds to a few hundred milliseconds by avoiding massive index and data‑page scans.
Buffer PoolIndexLIMIT
0 likes · 8 min read

The article explains that when checking for the existence of records, using SELECT count(*) is inefficient and proposes replacing it with SELECT 1 … LIMIT 1, showing Java code examples and highlighting performance gains and reduced index usage.
COUNTExistence CheckLIMIT
0 likes · 3 min read

This article explains why using SELECT 1 with LIMIT 1 is a more efficient alternative to COUNT(*) when checking for the existence of rows, shows the common and optimized SQL/Java code patterns, and discusses the performance benefits and impact on index usage.
COUNTExistence CheckLIMIT
0 likes · 3 min read

The article explains why using SELECT 1 with LIMIT 1 is a more efficient alternative to COUNT(*) for existence checks in SQL and shows how to simplify the corresponding Java code for better performance.
COUNTExistence CheckJava
0 likes · 3 min read

The article explains why using SELECT 1 with LIMIT 1 to test for record existence is more efficient than counting rows with SELECT count(*), and shows how to rewrite both SQL and Java code for better performance.
Existence CheckLIMITSQL
0 likes · 3 min read

This article explains MySQL execution order, highlights performance problems with large OFFSET LIMIT queries, demonstrates how implicit type conversion, sub‑query rewriting, EXISTS removal, condition push‑down, and intermediate result push‑down can dramatically improve query speed, and provides practical SQL rewrite examples.
LIMITQuery PerformanceSQL Optimization
0 likes · 13 min read

The article explains why using LIMIT with a large offset in MySQL causes severe performance degradation, demonstrates the problem with real data, and shows how rewriting the query with a sub‑query that selects only primary keys dramatically reduces execution time by avoiding massive random I/O and buffer‑pool pollution.
Buffer PoolIndexLIMIT
0 likes · 8 min read

This article investigates why moving MySQL’s LIMIT clause outside a subquery can cause the ORDER BY sorting to be ignored in a LEFT JOIN, analyzes the optimizer’s behavior, and recommends placing both ORDER BY and LIMIT at the outermost query level for correct results.
LIMITORDER BYPagination
0 likes · 5 min read

The author discovers a puzzling MySQL bug where moving the LIMIT clause outside a nested SELECT causes the final result set to be ordered incorrectly, explains how ORDER BY inside subqueries is ignored during LEFT JOIN processing, and recommends placing ORDER BY and LIMIT at the outermost query level.
LIMITORDER BYPagination
0 likes · 5 min read

This article explains why large OFFSET values in MySQL LIMIT queries cause severe performance degradation and demonstrates how rewriting the query to fetch primary keys first and then joining reduces execution time from seconds to milliseconds, supported by buffer‑pool analysis and practical test results.
Buffer PoolIndexLIMIT
0 likes · 8 min read

This article examines why a MySQL query with a large OFFSET is extremely slow, demonstrates the performance gap with a join‑based rewrite, and validates the findings by comparing InnoDB buffer‑pool page usage, highlighting how unnecessary random I/O pollutes the cache.
Buffer PoolIndexLIMIT
0 likes · 8 min read

The article explains how using LIMIT with a large offset on a MySQL table forces the engine to scan hundreds of thousands of index rows and cluster‑index pages, dramatically increasing I/O, and shows a sub‑query join technique that reduces the scan to just the needed rows, cutting execution time from minutes to fractions of a second while also illustrating the impact on the InnoDB buffer pool.
LIMITQuery Optimizationmysql
0 likes · 10 min read


ITPUBDec 30, 2019 · Databases
This article presents eight practical MySQL optimization techniques—including smarter LIMIT usage, implicit type conversion fixes, join rewrites, mixed sorting, EXISTS elimination, condition pushdown, early row limiting, and intermediate result pushdown—each illustrated with SQL examples and performance comparisons that reduce query times from seconds to milliseconds.
LIMITPerformance TuningWITH
0 likes · 13 min read

This article presents concrete MySQL optimization techniques—including smarter LIMIT usage, avoiding implicit type conversion, rewriting updates and deletes with JOINs, handling mixed ordering, replacing EXISTS with joins, pushing down conditions, and leveraging WITH clauses—to dramatically reduce query execution times from seconds to milliseconds.
LIMITPerformance TuningSQL Optimization
0 likes · 14 min read

This article explains how using a large OFFSET in a MySQL LIMIT clause forces the server to scan hundreds of thousands of index and data pages, causing massive random I/O, and demonstrates a faster rewrite with an inner join that dramatically reduces buffer‑pool usage and execution time.
Buffer PoolIndexInnoDB
0 likes · 7 min read

This article explains the Java 8 Stream API's skip() and limit() intermediate operations, showing how they truncate streams, handling of edge cases, code examples, and key differences to help developers choose the right method for their data processing needs.
BackendJavaJava 8
0 likes · 4 min read


ITPUBJun 18, 2019 · Databases
This article examines why MySQL LIMIT pagination becomes slower as the offset grows, presents six practical methods—including direct LIMIT, primary‑key indexing, ordered index scans, prepared statements, sub‑queries, and joins—provides benchmark results on large tables, and distills actionable guidelines for designing covering and composite indexes to achieve fast, stable pagination.
LIMITPaginationSQL
0 likes · 12 min read

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.
LIMITORDER BYPerformance Tuning
0 likes · 6 min read


ITPUBMar 7, 2017 · Databases
This article examines the performance problems of MySQL LIMIT pagination on a table with over 800,000 rows, demonstrates timing tests for various offsets, and presents covering‑index techniques that dramatically reduce query time, including practical SQL examples.
Covering IndexLIMITPagination
0 likes · 6 min read


ITPUBNov 23, 2015 · Databases
In MySQL 5.6, using LIMIT together with ORDER BY on a non‑unique column can produce nondeterministic result sets, a known bug that persists regardless of indexing, and the article shows how adding a secondary unique sort key resolves the uncertainty for reliable pagination.
Database BugIndexingLIMIT
0 likes · 6 min read
