For decades, we’ve accepted a painful compromise: if you wanted logic inside the database, you had to write SQL/PSM (Persistent Stored Modules). It’s clunky, hard to debug, and declarative by nature, making it terrible for algorithmic tasks.

That ends with Percona Server 8.4.7-7.

We are introducing JS Stored Programs as a Tech Preview. Unlike Oracle’s implementation, which is restricted to the Enterprise Edition or Oracle Cloud, we have integrated the open-source Google V8 engine (the same engine powering Chrome and Node.js). This means you get modern programmability in a truly open-source environment.


While we are preparing to launch this as a tech preview, I want to highlight the three most immediate, high-impact use cases where JS blows SQL out of the water.

1. Complex Data Validation (“The Data Firewall”)

SQL CHECK constraints are useful but limited. If you need to validate complex strings (like emails, URLs, or international phone numbers) SQL forces you into a mess of SUBSTRING and REPLACE chains.

With the V8 engine, you have access to native JS Regular Expressions. You can create a “Data Firewall” that ensures garbage never hits your disk.

The Use Case: Validating an email address inside the DB to prevent bad data ingestion.

2. Native JSON Processing

MySQL has supported JSON types for years, but manipulating that JSON using SQL functions (JSON_EXTRACT, JSON_SET) is verbose and unnatural. JS is the native language of JSON.

In Percona Server 8.4.7-7, we automatically marshall MySQL JSON types into JS Objects. You don’t need to parse string blobs; you just work with the object.

The Use Case: API Response Shaping. Instead of fetching a massive JSON blob to your app just to filter it, do it in the database and save the network cost.

3. Computational Offloading (Orders of Magnitude Faster)

SQL engines are optimized for data retrieval (IO), not heavy computation (CPU). When you force SQL to do math, loops, or cryptographic hashing, it struggles with overhead.

Because V8 utilizes Just-In-Time (JIT) compilation, heavy computational tasks can run orders of magnitude faster than standard SQL stored procedures.

The Use Case: Fuzzy Matching using Levenshtein distance. Implementing this algorithm in SQL is slow and complex. In JS, it’s highly efficient.

You can then call this directly in your SELECT statements to rank search results instantly.


Current Status & The Roadmap

It is important to manage expectations: this is currently a Tech Preview.

The biggest difference between our implementation and Oracle’s right now is that you cannot yet execute SQL queries (like SELECT or UPDATE) from within the JS routine. Currently, the Tech Preview supports JS Stored Routines for pure data processing (Input → Calculation → Output).

We are actively working on bridging the SQL execution gap and adding module support. However, for data validation, JSON manipulation, and heavy math, the feature is ready for you to experiment with today.

Our mission, as always, is to close the gap between Community and Enterprise editions. This feature brings JS capability to the open-source version, removing the need for proprietary licenses. I invite you to install the component package from our main repository, enable it, and tell us what you think.

Note: External module loading (e.g., import) is not supported in this preview; library code must be included directly in the routine body.

Learn More

For a deep dive into the architecture, type mapping, and specific limitations, read the official documentation.

Getting Started This feature is available in the main repository for Percona Server 8.4.7-7.

  1. Install the Package: For RPM/Deb users, install the separate component package: sudo apt-get install percona-server-js (or yum install ...) (Note: Tarball users will find this included in the main package.)
  2. Enable the Component: Log into MySQL and run: INSTALL COMPONENT 'file://component_js_lang'; </aside>

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Daniël van Eeden

Does this make it possible to send notifications from stored procedures? e.g. calling a webhook? Sending metrics to prometheus? Send an email?

What about calling a HTTP API to do validation?