Common SQL Errors

MySQL Error 1705: ER_STMT_CACHE_FULL - How to Fix and Prevent

Galaxy Team
August 7, 2025

<p>The binary log statement cache exceeded max_binlog_stmt_cache_size, so MySQL aborted the multi-row statement and returned error 1705.</p>

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 1705 (ER_STMT_CACHE_FULL)?

<p>MySQL Error 1705: ER_STMT_CACHE_FULL means the binary log statement cache grew beyond the max_binlog_stmt_cache_size setting during a transaction. Increase the variable or rewrite the statement to fit within the limit to resolve the error.</p>

Error Highlights

Typical Error Message

Multi-row statements required more than

Error Type

Resource Limit Error

Language

MySQL

Symbol

ER_STMT_CACHE_FULL

Error Code

1705

SQL State

HY000

Explanation

Table of Contents

What does "Multi-row statements required more than 'max_binlog_stmt_cache_size' bytes of storage" mean?

MySQL keeps each transactional statement in a per-session binary log cache before writing it to the binary log. When a single multi-row statement outgrows the max_binlog_stmt_cache_size threshold, the server stops execution and returns error 1705 (ER_STMT_CACHE_FULL).

The error protects the server from allocating excessive memory, but it also halts the offending transaction. Production inserts, updates, or deletes that touch many rows are most often affected.

When does MySQL raise error 1705?

The error appears during transactional statements such as INSERT ... SELECT, bulk UPDATE, or large DELETE that generate more cached data than allowed. It is common on replication masters where binary logging is enabled and the default cache limit remains unchanged.

Because DDL is logged immediately, it rarely causes this error. Only DML statements that accumulate in the statement cache trigger the size check.

Why is fixing error 1705 important?

If the cache limit is hit, the entire statement rolls back, leaving data unchanged and applications in an inconsistent state. On replication setups, failing statements break consistency between master and replicas, causing lag or stop events.

Addressing the root cause prevents repeated transaction failures, protects data integrity, and maintains replication health.

Key variables involved

max_binlog_stmt_cache_size defines the hard cap for the statement cache. binlog_stmt_cache_size controls its initial allocation per session. The global log_bin variable must be ON for the cache to exist.

Adjusting these values or rewriting queries usually resolves the issue quickly.

How Galaxy helps

Galaxy flags long-running or oversized multi-row queries in the editor and suggests rewriting strategies or variable changes before execution, reducing the chance of hitting ER_STMT_CACHE_FULL in production.

Common Causes

Large INSERT ... SELECT statements

Copying millions of rows in a single statement quickly exceeds the default 256MB limit, filling the binary log cache.

Bulk UPDATE or DELETE operations

Mass updates that touch wide rows generate voluminous before/after images in the cache, triggering the size ceiling.

High row size with many columns

Tables containing large BLOB or TEXT columns inflate cached data even for moderate row counts.

Small max_binlog_stmt_cache_size setting

Systems running with the historical default may simply need a larger limit to accommodate modern workloads.

Related Errors

Error 1180: ER_STMT_CACHE_SIZE_OVERFLOW

Similar cache overflow but triggered by binlog_cache_size during a transaction, not max_binlog_stmt_cache_size.

Error 1317: Query execution was interrupted

Occurs when a user kills a long-running bulk operation often attempted after repeated cache full errors.

Error 1206: The total number of locks exceeds the lock table size

Appears during huge UPDATE or DELETE statements that also risk hitting the statement cache limit.

Error 1615: Prepared statement needs to be re-prepared

Large temporary tables from batched inserts can invalidate prepared statements soon after fixing cache issues.

FAQs

Can I set max_binlog_stmt_cache_size to unlimited?

No. The variable must be a positive integer up to 4GB. Setting it too high risks exhausting server memory.

Does increasing binlog_stmt_cache_size fix error 1705?

Not always. binlog_stmt_cache_size is the starting size. The error is thrown when the cache grows beyond max_binlog_stmt_cache_size.

Will row-based replication remove the limit?

Row-based format reduces cache usage but does not eliminate it entirely. Very large batches can still hit the limit.

Is this error recorded in the error log?

Yes. MySQL logs ER_STMT_CACHE_FULL with the connection ID, making it easier to trace the failing session.

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