How to Fix MySQL Error 1104 (ER_TOO_BIG_SELECT)
You see mysql error 1104 when a query tries to read more rows than the database allows. You fix this error by adding table indexes, rewriting the query filter, or raising the row limit. Database admins use row limits to stop bad queries from crashing shared servers. When a query lacks a good filter, the engine calculates that it must scan millions of rows. The server blocks the request before it even runs and returns the ER_TOO_BIG_SELECT symbol with SQLSTATE 42000. Why mysql error 1104 happe
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You see mysql error 1104 when a query tries to read more rows than the database allows. You fix this error by adding table indexes, rewriting the query filter, or raising the row limit.
Database admins use row limits to stop bad queries from crashing shared servers. When a query lacks a good filter, the engine calculates that it must scan millions of rows. The server blocks the request before it even runs and returns the ER_TOO_BIG_SELECT symbol with SQLSTATE 42000.
Why mysql error 1104 happens in your database
The MySQL query planner checks every select statement before it reads any data from disk. It estimates how many rows the query will examine across all joined tables. If that estimate exceeds the max join size rule, the engine aborts the run right away.
Missing indexes are the most common cause of this failure in growing apps. When you join two or three tables without indexes on the join columns, the row count multiplies fast. A small join across three tables with ten thousand rows each can force one trillion row checks.
Cartesian joins also trigger this limit during ad hoc data checks or reporting runs. This happens when a developer forgets to write the join condition between two large tables. The database engine protects the host CPU and memory by rejecting the query at the planning stage.
Shared database hosts often set a strict max join size rule by default. When your app grows and tables gain more rows, old queries cross that threshold. A query that worked fine last month will start failing today as table sizes expand.
How to find the slow query and check the execution plan
Start your fix by finding the exact query that threw the error in your app logs. Run the query plan check in your database client to see how the engine reads each table. Look for full table scans where the planner reads every single row instead of using an index.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Check the estimated row count for each table in the query plan output. Multiply those row counts together to see the total work the database expects to do. Any table with a high row count and no active key is your main target for a fix.
Inspect the filter clauses and join conditions in your statement for data type mismatches. Comparing a text column to a number forces the engine to skip indexes and scan every row. Fixing the column types lets the planner use an existing key and drops the row estimate.
How to fix the error in production
The best fix is to add an index on the columns used in your join and filter clauses. An index lets the database jump straight to the matching rows without scanning the whole table. Once you build the index, the estimated row count drops and the error goes away.
Rewrite your query to filter rows earlier and fetch only the columns and records your app needs. Break massive reporting queries into smaller batches that check a narrow date range or ID block. Smaller queries stay well under the server row limit and keep the database fast for other users.
Sometimes a valid analytics query must scan millions of rows when no index can help. In those rare cases, enable the big selects setting only for that single database session. Avoid turning off row limits for the whole server, because one bad query could freeze production.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
What does SQLSTATE 42000 mean with error 1104?
SQLSTATE 42000 is the standard error category for syntax rules or access rule rejections in SQL. For error 1104, it means the server rejected your query because it broke the row scan limit.
Should I enable big selects globally on my production server?
No, turning on big selects for the whole server removes an important safety check against bad queries. Instead, add indexes to your tables or enable the setting only inside the specific reporting session.
Why did this error start happening without any code changes?
Your tables grew larger over time as users added more records to the app. The query planner now estimates a higher row count that crosses your server max join size limit.
Related guides
In this post