Tagged articles
30 articles
Page 1 of 1
Laravel Tech Community
Laravel Tech Community
Aug 20, 2025 · Databases

Three Powerful Ways to Perform Cumulative Queries in SQL

This article explains three techniques for performing cumulative queries in SQL—using a subquery, a Cartesian product with grouping, and a window function—detailing when each method is appropriate, especially for MySQL versions lacking native window support.

Subquerycartesian joincumulative query
0 likes · 2 min read
Three Powerful Ways to Perform Cumulative Queries in SQL
dbaplus Community
dbaplus Community
Mar 12, 2025 · Databases

Why Does LIMIT Pagination Slow Down? Deep Dive and Optimizations

This article reproduces a slow‑query scenario caused by deep pagination with LIMIT, explains the underlying index mechanics, and presents several practical SQL techniques—subquery, INNER JOIN, and anchor‑record methods—to dramatically reduce execution time.

Back-tableINNER JOINIndex Optimization
0 likes · 11 min read
Why Does LIMIT Pagination Slow Down? Deep Dive and Optimizations
Open Source Linux
Open Source Linux
May 5, 2023 · Databases

Mastering Subquery Unnesting: Turn Correlated Queries into Fast Joins

This article explains why correlated subqueries are a performance bottleneck, introduces the Apply (Correlated Join) operator and a systematic set of transformation rules that push Apply down and replace subqueries with efficient joins, covering scalar, existential, and quantified subqueries, aggregation handling, and set operations, all illustrated with TPC‑H examples.

Apply OperatorDatabase EnginesDecorrelate
0 likes · 17 min read
Mastering Subquery Unnesting: Turn Correlated Queries into Fast Joins
Liangxu Linux
Liangxu Linux
Apr 25, 2023 · Databases

How to Unnest Correlated Subqueries for Faster SQL Execution

This article explains why correlated subqueries are costly, introduces the Apply (correlated join) operator, and presents a series of systematic transformation rules that convert scalar, existential, and aggregate subqueries into efficient join‑based plans while preserving SQL semantics.

Apply OperatorDecorrelationSubquery
0 likes · 17 min read
How to Unnest Correlated Subqueries for Faster SQL Execution
Aikesheng Open Source Community
Aikesheng Open Source Community
Dec 27, 2022 · Databases

Understanding How MySQL Converts Uncorrelated Subqueries to Correlated Subqueries and Their Execution Plans

This article explains the process by which MySQL transforms uncorrelated IN subqueries into correlated subqueries, details the differences in EXPLAIN output columns, explores optimizer trace information, compares materialization versus correlated execution costs, and provides best‑practice recommendations for writing efficient queries.

Database PerformanceOptimizer_traceSubquery
0 likes · 15 min read
Understanding How MySQL Converts Uncorrelated Subqueries to Correlated Subqueries and Their Execution Plans
Liangxu Linux
Liangxu Linux
Jul 9, 2022 · Databases

How Indexes Transform MySQL Subquery Performance: A Deep Dive

This article walks through a MySQL 5.6 scenario where a subquery that originally took over eight hours is accelerated by orders of magnitude through strategic index creation, query rewriting, and join optimization, illustrating the impact of single‑column, composite, and covering indexes on execution plans.

Index OptimizationJOINSubquery
0 likes · 13 min read
How Indexes Transform MySQL Subquery Performance: A Deep Dive
dbaplus Community
dbaplus Community
Jul 4, 2022 · Databases

Why Large‑Offset LIMIT Is Slow in MySQL and How to Speed It Up

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.

InnoDBLIMITSubquery
0 likes · 9 min read
Why Large‑Offset LIMIT Is Slow in MySQL and How to Speed It Up
Programmer DD
Programmer DD
Apr 14, 2022 · Databases

How to Speed Up MySQL LIMIT Pagination from 16 s to 0.3 s with Subquery Optimization

This article demonstrates how a MySQL pagination query on a 9.5‑million‑row table that originally took over 16 seconds can be accelerated to under 0.4 seconds by moving the LIMIT condition into a subquery that selects only primary‑key IDs and then joining to retrieve the remaining columns, with detailed code and experimental verification.

InnoDBLimit OptimizationSubquery
0 likes · 10 min read
How to Speed Up MySQL LIMIT Pagination from 16 s to 0.3 s with Subquery Optimization
Top Architect
Top Architect
Jan 22, 2022 · Databases

Optimizing MySQL Pagination Queries with Subqueries and Buffer‑Pool Analysis

The article explains why large‑offset LIMIT queries on a MySQL table with millions of rows are slow, demonstrates how rewriting the query to use a subquery that first selects primary‑key IDs dramatically reduces execution time, and validates the improvement by measuring buffer‑pool page usage.

Database PerformanceSubquerybuffer pool
0 likes · 9 min read
Optimizing MySQL Pagination Queries with Subqueries and Buffer‑Pool Analysis
Java Backend Technology
Java Backend Technology
Jan 15, 2022 · Databases

Why Large OFFSETs Slow MySQL Queries and How Subquery Optimization Fixes It

The article explains how using a large OFFSET in MySQL pagination forces the server to read and discard many rows, causing severe performance degradation, and demonstrates that rewriting the query to first fetch primary‑key IDs via a subquery dramatically reduces I/O and execution time, with buffer‑pool experiments confirming the improvement.

Subquerybuffer poolmysql
0 likes · 9 min read
Why Large OFFSETs Slow MySQL Queries and How Subquery Optimization Fixes It
Alibaba Cloud Developer
Alibaba Cloud Developer
Sep 17, 2021 · Databases

How MySQL 8.0 Optimizer Transforms Complex Subqueries and Joins

This article explains MySQL 8.0’s optimizer architecture and walks through the detailed transformation steps for subqueries, scalar‑to‑derived conversions, flattening, join simplification, partition pruning, and condition push‑down, illustrating each phase with code examples and execution‑plan screenshots.

Derived TablesJOINSubquery
0 likes · 25 min read
How MySQL 8.0 Optimizer Transforms Complex Subqueries and Joins
Python Programming Learning Circle
Python Programming Learning Circle
Jun 22, 2021 · Databases

Decorrelation of Correlated Subqueries: Theory, Operators, and Optimization Rules

This article explains why correlated subqueries are a performance bottleneck, introduces the Apply (Correlated Join) operator, classifies subquery types, shows how to transform them into efficient joins, and discusses rule‑based push‑down techniques for Project, Filter, Aggregate, and Set operations.

Apply OperatorDecorrelationSubquery
0 likes · 15 min read
Decorrelation of Correlated Subqueries: Theory, Operators, and Optimization Rules
Programmer DD
Programmer DD
Apr 26, 2021 · Databases

Why MySQL Subqueries Slow Down and How to Optimize Them

This article explains why MySQL subqueries often cause performance bottlenecks, describes the underlying execution mechanism, and presents practical optimization strategies—including semi‑join, materialization, and EXISTS—plus a real‑world case study showing how to rewrite a slow query into a fast join.

Subquerymysqloptimization
0 likes · 7 min read
Why MySQL Subqueries Slow Down and How to Optimize Them
ITPUB
ITPUB
Feb 5, 2021 · Databases

Mastering Subquery Unnesting: Theory, Apply Operator, and Practical Rules

This article explains why correlated subqueries are a performance bottleneck, introduces the Apply (Correlated Join) operator, and presents a comprehensive set of transformation rules—including basic unnesting, Project/Filter push‑down, Aggregate handling, and Set‑operation rewrites—to convert subqueries into efficient join plans for modern SQL engines.

Apply OperatorSubqueryUnnesting
0 likes · 18 min read
Mastering Subquery Unnesting: Theory, Apply Operator, and Practical Rules
21CTO
21CTO
Jan 5, 2021 · Databases

5 Essential Rules for Writing High‑Performance SQL Queries

This article presents five practical rules—return only needed rows, use proper indexes, avoid subqueries, replace OFFSET pagination with key‑based limits, and understand SQL's logical execution order—to help developers write efficient, high‑performance SQL queries across major relational databases.

Subqueryindexespagination
0 likes · 13 min read
5 Essential Rules for Writing High‑Performance SQL Queries
Architect
Architect
Dec 10, 2020 · Databases

Optimizing MySQL LIMIT Offset Queries with Subqueries to Reduce Table Scans

This article demonstrates how to dramatically improve MySQL LIMIT offset query performance by moving the filter into a subquery that selects only primary keys, then joining to retrieve full rows, and validates the approach with buffer pool statistics and execution time measurements.

Subquerybuffer poollimit offset
0 likes · 9 min read
Optimizing MySQL LIMIT Offset Queries with Subqueries to Reduce Table Scans
Aikesheng Open Source Community
Aikesheng Open Source Community
Nov 20, 2020 · Databases

Optimizing a Slow MySQL 5.7 Query for Detecting Tables Without Primary or Unique Keys

This article examines why a MySQL 5.7 query that finds tables lacking primary or unique keys runs extremely slowly, demonstrates an experiment reproducing the issue, analyzes the optimizer's subquery rewrite, and shows how adding hints and materialization reduces execution time from over 16 seconds to under one second.

Information SchemaSubquerymysql
0 likes · 4 min read
Optimizing a Slow MySQL 5.7 Query for Detecting Tables Without Primary or Unique Keys
IT Architects Alliance
IT Architects Alliance
Nov 21, 2019 · Databases

Why MySQL Subqueries Took Hours and How Indexes Fixed It

A MySQL 5.6 database with three large tables suffered a 30,000‑second query when searching for students scoring 100 in a specific subject; by analyzing the execution plan, adding indexes on filter columns, and rewriting the query as a join, execution time dropped to under a second.

JOINSQL OptimizationSubquery
0 likes · 8 min read
Why MySQL Subqueries Took Hours and How Indexes Fixed It
21CTO
21CTO
Nov 21, 2019 · Databases

How I Reduced a 30,000‑second MySQL Query to 0.001s with Indexes & Joins

This article walks through a real‑world MySQL performance case where a nested sub‑query on millions of rows took over eight hours, explains why the plan used full table scans, and shows step‑by‑step index creation and query rewrites that cut the execution time to a millisecond.

JOINSQL OptimizationSubquery
0 likes · 7 min read
How I Reduced a 30,000‑second MySQL Query to 0.001s with Indexes & Joins
MaGe Linux Operations
MaGe Linux Operations
Feb 28, 2019 · Databases

How to Find and Remove Duplicate Rows in MySQL

This article shows step‑by‑step how to identify duplicate rows in a MySQL table—whether the duplication is based on a single column, multiple columns, or either column—and provides reliable SQL patterns, including GROUP BY with HAVING, UNION, sub‑queries, temporary tables, and a safe DELETE statement to clean the data.

DELETEGROUP BYHAVING
0 likes · 11 min read
How to Find and Remove Duplicate Rows in MySQL
ITPUB
ITPUB
Nov 3, 2016 · Databases

Why Nested Subqueries Slow Down Your SQL Queries and How to Diagnose Them

The article recounts a real‑world incident where a complex SQL query took over 20 seconds, explains how to pinpoint whether the slowdown originates from joins or nested subqueries, and shares practical steps and insights for diagnosing and fixing such performance issues.

Subquerydatabaseoptimization
0 likes · 6 min read
Why Nested Subqueries Slow Down Your SQL Queries and How to Diagnose Them