How to Fix MySQL Error 3674 (WARN_USELESS_SPATIAL_INDEX)
You see mysql error 3674 when a spatial index lacks a spatial reference ID on its column. You fix it by setting a single spatial reference ID on the column and rebuilding the index. The database engine returns this notice with the symbol WARN_USELESS_SPATIAL_INDEX and SQLSTATE HY000. The query planner skips the spatial index until you restrict the column to one coordinate system. As a result, location queries read every row in the table and slow down your app. Why mysql error 3674 happens in
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 3674 when a spatial index lacks a spatial reference ID on its column. You fix it by setting a single spatial reference ID on the column and rebuilding the index.
The database engine returns this notice with the symbol WARN_USELESS_SPATIAL_INDEX and SQLSTATE HY000. The query planner skips the spatial index until you restrict the column to one coordinate system. As a result, location queries read every row in the table and slow down your app.
Why mysql error 3674 happens in your database
The official warning text says the query planner will not use the spatial index on the column. This happens because the spatial column does not have an SRID attribute defined in the table schema. Without that attribute, the column can hold shapes from many different map coordinate systems at once.
A spatial index needs one fixed coordinate system to calculate distance and overlap math with speed. If rows mix flat grid coordinates and round earth coordinates, the index tree cannot sort them together. So, the database builds the index on disk, but the query planner ignores it during reads.
Teams often hit this warning after a database upgrade or when importing map tables from older backups. Older database builds allowed mixed coordinate systems inside spatial indexes without raising a schema warning. Newer builds flag this issue right when you create or alter the table structure.
How to check your spatial columns and rows
Before you change the table, you must check the existing data inside the spatial column. Permitted row (unless row-level security applies) in that column must use the exact same spatial reference ID value. If some rows use zero and others use a geographic value, the schema update will fail.
Run a read query that groups the table by the spatial reference ID of your geometry column. This quick check shows you how many different coordinate systems exist in the table right now. If you find mixed values, you must update the mismatched rows before you change the column rule.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
During this check, make sure your team uses a safe read role in production. You should also apply data masking so queries rewrite emails, phone numbers, card numbers, and national IDs. This keeps sensitive user records safe while engineers inspect location columns in the same table.
How to fix the spatial index safely in production
Once all rows share one coordinate system, you are ready to fix the table schema. First, drop the useless spatial index from the table so you can modify the column definition. Next, update the spatial column definition so it enforces the single spatial reference ID attribute.
After the column rule is in place, create the spatial index on that column again. The database will build a valid index tree that matches the fixed coordinate system of the column. You can then check the query plan to confirm that location queries now use the new index.
Run these schema changes during a low traffic window to avoid locking rows for active users. Always test the column change on a staging copy of your production data first. Have a peer review the schema change request before running it on the live database.
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
Does mysql error 3674 stop my table from saving new rows?
No, this code is a warning with SQLSTATE HY000 rather than a hard failure. Your app can still read and write rows, but spatial queries will run slow full table scans.
Can I add the SRID attribute without rebuilding the spatial index?
No, you must drop the existing spatial index before you change the column attribute. After you update the column with the SRID rule, you must create the spatial index again.
What happens if my column has null values when I add a spatial index?
Columns included in a spatial index cannot allow null values in the table schema. You must fill in any null geometry rows and set the column to not null first.
Related guides
In this post