Make a JSON path searchable with an index.
Section: Pattern catalog
MySQL generated column from JSON
sql
sql
ALTER TABLE events
ADD COLUMN event_type VARCHAR(64) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(payload, '$.type'))) STORED,
ADD INDEX idx_events_event_type (event_type);Explanation
Generated columns are a common way to index computed values in MySQL.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Pattern catalog
PostgreSQL case-insensitive email lookup
Index the normalized expression you actually query.
SQLite partial index for active rows
Shrink the index to the rows that matter most.