Explore Secondary Storage for Analytics
Configure GridGain 9 secondary columnar storage to run analytical queries alongside transactional workloads in a hybrid HTAP setup.
Overview
GridGain secondary storage allows you to create hybrid transactional/analytical processing (HTAP) systems by configuring tables to store data in both primary and secondary storage engines. This approach enables you to optimize your database for both transactional and analytical workloads simultaneously. The primary storage engine (usually aipersist) handles write operations and transactional queries, while the secondary storage (columnar) is optimized for analytical queries.
This guide will show you how to configure and use secondary storage for analytical workloads.
Prerequisites
Before you begin, ensure you have:
A license with secondary storage add-on;
Basic understanding of distribution zones;
Basic understanding of storage profiles.
Configuring Secondary Storage
Step 1: Create a Columnar Storage Profile
First, create a storage profile that uses the columnar storage engine:
node config update "ignite.storage.profiles:{columnar{engine:columnar}}"After updating the configuration, restart the node for the changes to take effect.
Step 2: Create a Distribution Zone with Multiple Storage Profiles
After restarting the node, enter the sql editing mode of the CLI tool with the sql command.
Then, create a distribution zone that supports both the default storage profile (for primary storage) and the columnar storage profile (for secondary storage):
This distribution zone will now be able to store data using either the default or columnar storage profiles.
Step 3: Create Tables with Primary and Secondary Storage
Now you can create tables that use both storage profiles:
In this example:
The
PRIMARY ZONEandPRIMARY STORAGE PROFILEclauses define where and how the primary data will be storedThe
SECONDARY ZONEandSECONDARY STORAGE PROFILEclauses define where and how the secondary data will be stored
Using Secondary Storage
Writing Data
Data is always written to the primary storage first, then automatically propagated to the secondary storage. You cannot write directly to the secondary storage.
Example of inserting data:
Reading from Primary Storage
By default, all queries read from the primary storage:
Reading from Secondary Storage
To read from the secondary storage, use the use_secondary_storage query hint:
Understanding Query Plans
You can use the EXPLAIN PLAN statement to see how queries will be executed against either the primary or secondary storage:
You can see the useSecondaryStorage: true explanation when using secondary storage, for example:
Mixed Workloads
You can mix data from primary and secondary storage in a single query by applying the use_secondary_storage hint to specific tables.
First, let's create an extra table that will not be using secondary storage and add some data to it:
Since no distribution zone or storage profile is specified, this table will be created in the default distribution zone, and will not be replicated to secondary storage.
In this example, data from the Person table is read from secondary storage, while data from the Orders table is read from primary storage.
Considerations
Data Consistency
Be aware that secondary storage is updated asynchronously after primary storage. This means that secondary storage may be slightly behind primary storage (typically under a second). For queries requiring absolute consistency, use primary storage.
Workload Separation
Use primary storage for transactional workloads (OLTP) that require frequent writes and point queries;
Use secondary storage for analytical workloads (OLAP) that involve scanning large amounts of data.
Query Optimization
Analytical queries that scan large portions of tables will typically perform better on columnar secondary storage;
Point lookups by primary key often perform better on primary storage;
Use
EXPLAIN PLANto understand how your queries will be executed.
Resource Planning
Consider allocating different nodes or resource pools for transactional and analytical workloads to prevent analytical queries from affecting the performance of transactional operations.
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

