Common SQL Errors

MySQL Error 1669: ER_UNUSED4 - Unsafe INSERT DELAYED Statement

Galaxy Team
August 7, 2025

<p>MySQL raises error 1669 (ER_UNUSED4) when a query uses the legacy INSERT DELAYED clause, which is considered unsafe because the actual insert time cannot be predicted.</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 1669 (ER_UNUSED4)?

<p>MySQL Error 1669: ER_UNUSED4 occurs when you run INSERT DELAYED. The optimizer flags it as unsafe since row-insert timing is unpredictable. Remove the DELAYED keyword or switch to standard INSERT to resolve the issue.</p>

Error Highlights

Typical Error Message

The statement is unsafe because it uses INSERT DELAYED.

Error Type

Unsafe Statement Error

Language

MySQL

Symbol

ER_UNUSED4

Error Code

1669

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1669 (ER_UNUSED4)?

Error 1669 triggers when a statement includes INSERT DELAYED. MySQL marks the query as unsafe because the engine cannot guarantee when rows are finally written. The server therefore rejects the statement to protect data consistency.

The error appears with SQLSTATE HY000 and the message “The statement is unsafe because it uses INSERT DELAYED.” The clause was deprecated in MySQL 5.6 and removed in later versions.

What Causes This Error?

The direct cause is the presence of the DELAYED keyword in an INSERT statement. The keyword asks the server to queue the insert for asynchronous execution, breaking determinism.

Upgraded servers running versions after 5.6 reject DELAYED outright. Replication or binary-logging setups also flag it as unsafe to avoid data drift between masters and replicas.

How to Fix MySQL Error 1669

Remove the DELAYED modifier and execute a normal INSERT or INSERT ... ON DUPLICATE KEY UPDATE. This guarantees immediate insertion and satisfies the optimizer safety checks.

If you need throughput, batch multiple rows into one INSERT or use LOAD DATA INFILE. Both options are safe and performant.

Common Scenarios and Solutions

Legacy application code often still emits INSERT DELAYED. Refactor those code paths to plain INSERT statements. Test with EXPLAIN to confirm the new query plan.

Scheduled scripts may rely on DELAYED for non-critical logging. Replace with INSERT IGNORE or buffered message queues such as Kafka to decouple write latency safely.

Best Practices to Avoid This Error

Avoid deprecated SQL features in application code. Set sql_mode='STRICT_ALL_TABLES' and upgrade libraries to catch unsafe clauses during development.

Monitor slow query logs in Galaxy’s editor to detect remaining DELAYED statements before pushing to production.

Related Errors and Solutions

Error 1135 (HY000) rejects inserts into read-only replicas. Remove write attempts or switch the session to the primary server.

Error 1592 warns about unsafe statements for statement-based replication. Convert to row-based logging or rewrite the query.

Common Causes

Deprecated Keyword Still Present

Older codebases generated before MySQL 5.6 continue to emit INSERT DELAYED, causing modern servers to fail.

Replication Safety Checks

Statement-based replication refuses asynchronous inserts to prevent data drift, surfacing error 1669 on the master.

Binary Logging in MIXED Mode

MIXED logging treats DELAYED as nondeterministic. The server therefore blocks the statement to ensure deterministic replay.

Related Errors

Error 1592: Statement is Unsafe

Occurs when non-deterministic functions or LIMIT without ORDER BY are used in statement-based replication.

Error 1135: Can't Insert in Read-Only Mode

Triggered when writes target a replica with super_read_only=1.

Error 1062: Duplicate Entry

Appears when an INSERT violates a UNIQUE constraint, requiring ON DUPLICATE KEY handling.

FAQs

Is INSERT DELAYED still supported in MySQL?

No. The keyword was deprecated in 5.6 and removed in 8.0, so any use triggers error 1669.

Can I bypass the safety check?

No reliable method exists. The engine removed DELAYED support entirely for data-consistency reasons.

What is the best replacement for INSERT DELAYED?

Batch regular INSERT statements or use LOAD DATA INFILE for bulk loads. Both are safe and performant.

How does Galaxy help locate unsafe queries?

Galaxy’s linting and AI copilot highlight deprecated keywords and suggest compliant alternatives during query editing.

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