GridGain JSON Basics
Populate a GridGain table with JSON data, query it with JSON_VALUE and JSON_QUERY, and speed up queries by flattening fields into indexed columns.
Introduction
For users storing data in the JSON format - for example, in NoSQL document databases - GridGain offers a number of new functions that simplify working with JSON data. This tutorial shows you how to populate a database with sample JSON data and use the JSON functions to improve query performance.
Sample Data
The sample JSON data for this tutorial are as follows:
The datasets are relatively large (~15 Kb minified), with many data rows. You may want to tune the node memory defaults (for example, in bin/ignite.sh).
Populate the Database
Run a GridGain node.
Connect to the node using the embedded sqlline:
./bin/sqlline.sh --verbose=true -u jdbc:ignite:thin://127.0.0.1:10800Create a table to hold the JSON data.
CREATE TABLE shows(id INT PRIMARY KEY, data VARCHAR);
For the sake of example comparison, produce duplicates and a few unique rows to be included in the query results.
Query JSON Data
Retrieve a Great Britain (GB) TV show whose first episode aired before 2005:
The query plan uses PUBLIC.SHOWS.__SCAN_ and simply scans the entire table:
The query returns the following result:
Improve Performance With Indexes
Now put "JSON" and "performance" in the same sentence by preparing your data and adding indexes.
Your query uses a couple of common fields related to the first episode, hence you can flatten these into separate columns and use them as indexes (read the automation section below):
Now, rewrite the initial query to use the new index:
Note that the query plan uses the created index - PUBLIC.SHOWS_FIRST_EPISODE_NAME_AIRST:
The query result is:
Wasn't that fast? From 23.731 sec to 0.007 sec - more than x3300 improvement!
Now clean up (optional):
Automation
Flattening using UPDATE is good for this tutorial. To automate this, you can add CacheInterceptor to your CacheConfiguration:
Conclusion
You have successfully completed the tutorial. You have learned how to query semi-structured JSON data, as well as how to improve the JSON query performance by rearranging the data and adding well-chosen indexes.
Related
JSON Functions for the full reference on
JSON_VALUEandJSON_QUERYEnabling modules for enabling the
gridgain-sqlmodule
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

