For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

JSON functions are available only in GridGain Enterprise and Ultimate editions, version 8.9 and above.

To proceed with this tutorial, you need to enable the 'gridgain-sql' module. The module's JSON library needs the SLF4J API, which the base libs folder does not include, so enable the ignite-slf4j module too. Without it, the JSON functions fail with NoClassDefFoundError: org/slf4j/LoggerFactory.

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

  1. Run a GridGain node.

  2. Connect to the node using the embedded sqlline:

    ./bin/sqlline.sh --verbose=true -u jdbc:ignite:thin://127.0.0.1:10800
  3. Create a table to hold the JSON data.

    CREATE TABLE shows(id INT PRIMARY KEY, data VARCHAR);

Do not forget to escape single quotes ' with '' while using SQL.

  1. For the sake of example comparison, produce duplicates and a few unique rows to be included in the query results.

Query JSON Data

The difference between JSON_QUERY and JSON_VALUE is explained in JSON Functions.

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.

This page is: Copyright © 2026 MariaDB. All rights reserved.

spinner

Last updated

Was this helpful?