In December, MySQL announced the addition of a new feature, which allows for the execution of JavaScript code directly in the database (stored programs). This functionality has been available in Oracle Database since version 21c.
The purpose of running JavaScript code directly in the database is to minimize data movement, eliminating the need to fetch data beforehand. This is particularly useful in cases where there is a large amount of data or when the database is separate from the processing server. By reducing the time and cost associated with data retrieval, especially in cloud environments with expensive data transfer fees, this feature proves to be highly advantageous.
The JavaScript code is executed through Oracle’s GraalVM compiler, which supports multiple programming languages such as JavaScript, Java, Ruby, Python, and R. However, the GraalVM Enterprise Edition, a paid version, is required to utilize this capability.
An example of executing code involves using JavaScript in SQL commands, while the GraalVM runs within the VM-sandbox environment, ensuring that the code cannot interact with other modules of the MySQL server. This enhances the overall security of the system.
TLDR: MySQL now allows the execution of JavaScript code directly in the database, similar to the functionality already present in Oracle Database. This feature minimizes data movement, making it ideal for scenarios with large data volumes or separate databases and processing servers. The GraalVM compiler is used to run JavaScript code, enhancing security by confining it within the database environment.
Leave a Comment