MySQL 9.0 arrived in 2024 with significant additions to its JSON capabilities, JavaScript stored programs, and vector search functionality β positioning MySQL to compete more directly with PostgreSQL and specialist document databases. For enterprises running MySQL in production, this guide covers every major change and the migration considerations.
MySQL 9.0: Major Themes
MySQL 9.0 continues Oracle's strategy of adding capabilities that make MySQL viable for a broader range of modern application patterns without requiring migration to other databases. The headline additions are: JavaScript stored programs (using the GraalVM JavaScript engine), significant JSON and SQL/JSON improvements, vector data type support for AI/ML workloads, and performance improvements to the InnoDB storage engine. MySQL 9.0 is also the first LTS release under the new MySQL versioning scheme.
MySQL introduced a new dual-track versioning model in 2024: the Innovation Track (9.x) receives new features in quarterly releases and is not intended for production long-term use; the LTS Track (8.4, then 9.x LTS) receives 5 years of premier support plus 3 years extended support. Enterprises should run LTS releases in production and evaluate Innovation releases for upcoming feature planning.
JavaScript Stored Programs
MySQL 9.0 introduces the ability to write stored procedures and functions in JavaScript using the GraalVM JavaScript engine (multilingual engine supporting JavaScript in MySQL). This is a significant capability addition for teams that find MySQL's traditional stored procedure language (MySQL Procedural SQL) verbose and limiting.
-- Create a JavaScript stored function in MySQL 9.0
CREATE FUNCTION calculate_discount(price DECIMAL(10,2), tier VARCHAR(20))
RETURNS DECIMAL(10,2)
LANGUAGE JAVASCRIPT AS $$
const discountRates = { 'gold': 0.20, 'silver': 0.10, 'bronze': 0.05 };
const rate = discountRates[tier] || 0;
return price * (1 - rate);
$$;
JavaScript stored programs can access MySQL data using the session object and use modern JavaScript features including arrow functions, template literals, and destructuring. This makes complex data manipulation logic easier to express and test than traditional MySQL stored procedures β particularly for developers more comfortable with JavaScript than SQL procedural extensions.
JavaScript stored programs in MySQL 9.0 run in a sandboxed GraalVM environment β they cannot make external network calls, access the file system, or execute arbitrary system commands. They are isolated to data access via the session object. Performance characteristics differ from native stored procedures; profile before deploying performance-critical logic in JavaScript.
Vector Data Type and AI/ML Integration
MySQL 9.0 introduces a native VECTOR data type for storing floating-point vector embeddings, alongside approximate nearest-neighbour (ANN) search functions. This positions MySQL as a viable option for similarity search workloads β semantic search, recommendation systems, and RAG (Retrieval-Augmented Generation) pipelines β without requiring a separate vector database.
-- Create a table with a vector column
CREATE TABLE product_embeddings (
product_id INT PRIMARY KEY,
name VARCHAR(255),
description TEXT,
embedding VECTOR(1536) NOT NULL,
VECTOR INDEX idx_embedding (embedding)
);
-- Cosine similarity search
SELECT product_id, name,
VECTOR_COSINE_DISTANCE(embedding, :query_embedding) AS distance
FROM product_embeddings
ORDER BY distance ASC
LIMIT 10;
The vector support in MySQL 9.0 is competitive with PostgreSQL's pgvector extension for many use cases, particularly for teams already running MySQL who want to avoid adding a separate vector database (Pinecone, Weaviate, Qdrant) to their stack. For very large vector datasets or advanced HNSW index configurations, dedicated vector databases still offer better performance and more flexibility.
JSON and SQL/JSON Improvements
MySQL 9.0 adds SQL/JSON standard functions that improve portability with other databases (particularly PostgreSQL 17, which added similar functions) and provide more expressive JSON querying:
| New Function | Description | PostgreSQL Equivalent |
|---|---|---|
JSON_VALUE() | Extract scalar value using JSON path | ->> or JSON_VALUE() |
JSON_EXISTS() | Test if JSON path matches | @? operator |
JSON_QUERY() | Extract JSON object/array using path | jsonb_path_query() |
JSON_TABLE() enhancements | Convert JSON to relational rows (improved) | JSON_TABLE() |
JSON_SCHEMA_VALID() | Validate JSON against JSON Schema draft | No direct equivalent |
InnoDB and Performance Improvements
MySQL 9.0 includes several InnoDB improvements targeting high-concurrency OLTP workloads: improved lock scheduling that reduces deadlock frequency under high write concurrency; adaptive buffer pool prefetching for sequential scan-heavy workloads; and improved redo log performance that reduces I/O overhead for write-intensive applications. The optimizer also gains improvements to hash join performance and better cardinality estimation for complex multi-table queries.
Migration: MySQL 5.7 to 8.4 LTS to 9.x
MySQL 9.0 vs PostgreSQL 17 for New Projects
- Simpler replication setup (Group Replication, InnoDB Cluster)
- Wider managed service availability (AWS RDS, Azure, GCP)
- JavaScript stored programs (if JS is preferred over PL/pgSQL)
- Native vector support without extension
- Lower operational complexity for read-heavy web applications
- Richer SQL standard compliance (MERGE, window functions, CTE)
- Better JSONB performance and richer query operators
- More advanced indexing (partial indexes, expression indexes)
- Stronger ACID guarantees and concurrent access patterns
- Richer extension ecosystem (PostGIS, pgvector, TimescaleDB)