<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>
<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>
The statement is unsafe because it uses INSERT DELAYED.
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.
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.
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.
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.
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.
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.
Older codebases generated before MySQL 5.6 continue to emit INSERT DELAYED, causing modern servers to fail.
Statement-based replication refuses asynchronous inserts to prevent data drift, surfacing error 1669 on the master.
MIXED logging treats DELAYED as nondeterministic. The server therefore blocks the statement to ensure deterministic replay.
Occurs when non-deterministic functions or LIMIT without ORDER BY are used in statement-based replication.
Triggered when writes target a replica with super_read_only=1.
Appears when an INSERT violates a UNIQUE constraint, requiring ON DUPLICATE KEY handling.
No. The keyword was deprecated in 5.6 and removed in 8.0, so any use triggers error 1669.
No reliable method exists. The engine removed DELAYED support entirely for data-consistency reasons.
Batch regular INSERT statements or use LOAD DATA INFILE for bulk loads. Both are safe and performant.
Galaxy’s linting and AI copilot highlight deprecated keywords and suggest compliant alternatives during query editing.