MySQL 9.0 GA: JSON Multi-Valued Indexes, Parallel Query V2, and AI Optimizer Deep Dive
MySQL 9.0 introduces three major features: native JSON multi-valued indexes delivering 370x faster array queries, Parallel Query V2 with work-stealing achieving 7-8x speedups on analytical workloads, and an ML-based AI query optimizer that cuts index misselection from 12% to 2% and boosts complex query performance by 25-40%.
JSON Multi-Valued Indexes: Solving Array Query Performance
Prior to MySQL 9.0, JSON array fields could not be efficiently indexed. MySQL 8.0 offered only generated-column indexes for scalar values. MySQL 9.0 adds true multi-valued index support via the CAST(tags AS CHAR(64) ARRAY) syntax.
Creating a Multi-Valued Index
-- Create table with JSON array column
CREATE TABLE products (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255),
tags JSON,
INDEX mv_tags ((CAST(tags AS CHAR(64) ARRAY)))
);
-- Insert sample data
INSERT INTO products (name, tags) VALUES
('iPhone 16 Pro', '["electronics", "smartphone", "apple"]'),
('MacBook Pro M4', '["electronics", "laptop", "apple"]'),
('AirPods Pro 3', '["electronics", "audio", "apple"]');
-- Query using the index
SELECT * FROM products WHERE 'apple' MEMBER OF(tags);
-- Execution shifts from full table scan to index range scanPerformance Results
1 million rows: full scan 850 ms → multi-valued index 2.3 ms ( 370× faster)
Supported predicates: MEMBER OF(), JSON_CONTAINS(), JSON_OVERLAPS() Index compression improved by 45% , reducing disk I/O
Complexity drops from O(n) to O(log n) , eliminating the need to normalize JSON arrays into separate tables for performance.
Parallel Query V2: Work-Stealing Scheduler
MySQL 9.0 rewrites the parallel query engine across three stages: query decomposition, task scheduling, and result merging. The key addition is a dynamic work-stealing algorithm that balances load across threads, fixing the imbalance in MySQL 8.0's basic parallel read. Parallelism granularity moves from table-level down to partition-level.
Enabling Parallel Query V2
-- View current settings
SHOW VARIABLES LIKE 'innodb_parallel%';
-- Enable V2 (requires restart)
SET GLOBAL innodb_parallel_read_threads = 8;
SET GLOBAL innodb_parallel_query_enabled = ON;
SET GLOBAL innodb_parallel_query_threshold = 10000;
-- Hint for a specific large query
SELECT /*+ PARALLEL(8) */
category, COUNT(*) AS cnt, AVG(price) AS avg_price
FROM orders
WHERE order_date >= '2026-01-01'
GROUP BY category
ORDER BY cnt DESC;Benchmark Comparison (MySQL 8.4 vs 9.0)
Full-table aggregation (100M rows) : MySQL 8.4 45 s → MySQL 9.0 6.2 s ( +7.2× )
5-table JOIN : MySQL 8.4 120 s → MySQL 9.0 15 s ( +8× )
GROUP BY + ORDER BY : MySQL 8.4 78 s → MySQL 9.0 9.5 s ( +8.2× )
CPU utilization : MySQL 8.4 25% → MySQL 9.0 85% ( +3.4× )
Core improvement: Parallel Query V2 introduces a dynamic work-stealing algorithm that solves the load imbalance problem in V1. It also supports finer-grained parallelism control, refined from table-level to partition-level.
AI Query Optimizer: Learned Cost Model
MySQL 9.0 replaces the static cost model with a neural-network-based optimizer that learns from historical query patterns. It continuously improves execution plans — "the more you use it, the faster it gets."
Activation & Inspection
-- Enable AI optimizer
SET GLOBAL optimizer_ai_enabled = ON;
SET GLOBAL optimizer_ai_model = 'mysql-internal-v1';
SET GLOBAL optimizer_ai_learning_rate = 0.001;
-- Check learning status
SELECT * FROM performance_schema.ai_optimizer_status;
-- Manual training trigger
CALL mysql.train_ai_optimizer();
-- See AI-chosen plan
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 12345;
-- Output includes: "AI Optimizer: plan selected by neural network"Three Core Capabilities
Adaptive Index Selection — dynamically picks the best index based on actual data distribution, avoiding stale-statistics errors.
JOIN Order Optimization via Reinforcement Learning — automatically finds optimal join order for multi-table queries; complex queries gain 30–50% performance.
Query Result Cache Prediction — predicts hot data from access patterns and pre-warms the InnoDB Buffer Pool, cutting physical I/O.
Measured Impact
TPC-H benchmarks (Q5, Q7, Q9): 25–40% faster
Real-world e-commerce reporting: 35% average speedup
Index mis-selection rate: 12% → 2%
Caveat: The AI optimizer needs production runtime to converge; start with low-traffic workloads and monitor the learning curve. Use optimizer_ai_hints to override specific queries.
MySQL 8.4 vs 9.0 Feature Matrix
JSON Indexing : MySQL 8.4 — Generated-column (scalar only); MySQL 9.0 — Multi-valued index (array support)
Parallel Query : MySQL 8.4 — Basic parallel read; MySQL 9.0 — V2 engine + work-stealing
Query Optimization : MySQL 8.4 — Static cost model; MySQL 9.0 — AI neural-network optimizer
InnoDB Engine : MySQL 8.4 — Standard; MySQL 9.0 — Enhanced Buffer Pool
Replication : MySQL 8.4 — Basic parallel replication; MySQL 9.0 — Intelligent conflict detection
Security : MySQL 8.4 — TLS 1.3; MySQL 9.0 — TLS 1.3 + auto certificate rotation
Upgrade Strategy: Three-Phase Approach
Backup & Compatibility Check — run mysql_upgrade_checker to flag incompatible SQL syntax and configuration.
Canary Upgrade — upgrade replicas first, validate, then promote. MySQL 9.0 supports online upgrade for zero-downtime cutover.
Enable New Features — prioritize JSON multi-valued indexes and AI optimizer; enable Parallel Query V2 only after confirming sufficient CPU headroom.
Operational Notes
Minimum glibc 2.28 required — verify OS compatibility.
AI optimizer consumes ~ 5% extra CPU ; evaluate on low-spec servers.
JSON multi-valued indexes add ~ 3% write overhead ; load-test high-concurrency write workloads.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
