Common SQL Errors

MySQL Error 1104: ER_TOO_BIG_SELECT – How to Fix and Prevent

Galaxy Team
August 5, 2025

The query would scan more rows than MAX_JOIN_SIZE allows, so MySQL aborts it to protect server performance.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error code 1104 ER_TOO_BIG_SELECT?

MySQL Error 1104: ER_TOO_BIG_SELECT means the optimizer expects your SELECT to read more rows than the MAX_JOIN_SIZE limit. Reduce the estimated rows with indexes or filters, or run SET SQL_BIG_SELECTS = 1 to bypass the limit.

Error Highlights

Typical Error Message

The SELECT would examine more than MAX_JOIN_SIZE rows;

Error Type

Performance Error

Language

MySQL

Symbol

ER_TOO_BIG_SELECT

Error Code

1104

SQL State

Explanation

Table of Contents

What is MySQL error 1104 ER_TOO_BIG_SELECT?

MySQL raises error 1104 ER_TOO_BIG_SELECT when the optimizer estimates that a SELECT statement will examine more rows than the value in the MAX_JOIN_SIZE system variable.

The default limit is 18446744073709551615 unless overridden by the DBA.

The server cancels the statement and returns the message: “The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay.”

What Causes This Error?

Large joins that lack selective WHERE conditions create huge intermediate result sets, pushing the estimated row count above MAX_JOIN_SIZE.

Missing or unusable indexes force full table scans, inflating the optimizer’s estimate even if the final result is small.

How to Fix MySQL error 1104 ER_TOO_BIG_SELECT

Add tighter predicates, explicit JOIN conditions, and composite indexes on filtering columns to lower the estimated row count.

If the query is legitimate and cannot be rewritten, temporarily lift the limit with SET MAX_JOIN_SIZE = 0 or bypass checks with SET SQL_BIG_SELECTS = 1, ideally in a controlled session.

Common Scenarios and Solutions

Analytics queries that join fact tables to multiple dimensions often fail; adding date or tenant filters usually solves the issue.

Export scripts that unintentionally cross join tables trigger the error; rewriting to inner joins or adding ON clauses fixes it.

Ad-hoc queries in legacy apps break after migrating to stricter defaults; setting the variable at session level restores functionality without global risk.

Best Practices to Avoid This Error

Design indexes that match frequent WHERE clauses and JOIN keys to keep optimizer estimates low.

Monitor slow queries with EXPLAIN and update statistics so the optimizer makes accurate cardinality predictions.

Related Errors and Solutions

Error 1030 (HY000): Got error 28 from storage engine appears when temp tables fill the disk; adding filters and increasing tmpdir space helps.

Error 1135 (HY000): Host is blocked because of too many connections is different but also capacity-related; raising max_connections or using connection pooling resolves it.

.

Common Causes

Related Errors

FAQs

Can I disable MAX_JOIN_SIZE permanently?

You can set MAX_JOIN_SIZE = 0 in my.cnf to remove the limit globally, but this exposes the server to runaway queries. Prefer session overrides.

Is SET SQL_BIG_SELECTS = 1 safe in production?

Use it only for trusted sessions. Granting the SUPER privilege broadly allows costly queries that may degrade performance.

How do I know which table lacks indexes?

Run EXPLAIN on the failing query. Any row with type = ALL or rows = large numbers indicates missing or unused indexes.

Does Galaxy help avoid this error?

Galaxy’s AI copilot suggests optimal indexes and adds WHERE clauses while you type, lowering query cost before execution.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo