All articles

MySQL

Indexing JSON Columns in MySQL 8 with Virtual Columns

Oct 28, 2026 json · virtual columns · indexing · mysql 8

Keep your flexible JSON schema and get index-speed lookups: generated columns turn hot JSON paths into first-class index targets.

JSON columns are wonderful until a WHERE clause meets them. Without an index, every filter on a JSON path is a full scan. The MySQL 8 answer does not require sacrificing the flexible schema: virtual generated columns plus indexes on those columns give the optimizer a real target.

Inventory the paths your queries touch

Mine the digest tables and application queries for JSON_EXTRACT and -> operator usage. Each distinct hot path is a candidate for a generated column. Indexing paths nobody queries is wasted write amplification — measure first.

Type the column, don't let the optimizer guess

A generated column typed as the value it extracts (unsigned int, date, char) lets the optimizer use range scans and join statistics. Untyped JSON comparisons force per-row casts. The typing decision is where most of the speed lives.

Tags

json virtual columns indexing mysql 8

Related articles

Work with Burj

Your database deserves engineering, not guesswork.

Tell us what is slow — CPU, queries, migrations, or cost — and we will scope the smallest safe fix.

Plan an engagement