Flexible Parallelism
On this page
SingleStore supports Flexible Parallelism (FP), which allows multiple cores on the same node to access the same database partition.
As cores are added to a SingleStore system, it is possible to reach a point where there are more cores than database partitions on each leaf node.
Typically, analytic or hybrid transactional/analytic workloads gain benefits from FP, especially over time as you add more hardware and rebalance clusters.
Types of Flexible Parallelism
There are two types of FP in SingleStore: sub-partition parallelism and segment parallelism.
Sub-Partition Parallelism
Sub-partition parallelism is available on databases with sub-partitions.
Sub-partitions are divisions of database partitions.sub_
variable controls the number of sub-partitions that are created per physical partition.sub_
is set to a valid value greater than 0 (a power of 2 up to 64) before a database is created, sub-partitions are created and sub-partition parallelism is available to queries on columnstore tables in that database.
Sub-partitions must be created at database creation time and cannot be created on existing databases.
To add sub-partitions to an existing database, create a database with sub-partitions and copy the tables from the original database to the new one.CREATE TABLE LIKE
and INSERT… SELECT
.
The maximum sub-partition parallelism is sub_
* number of physical partitions.
Segment Parallelism
For certain query shapes, the engine processes segments of columnstore tables in parallel.
Segment parallelism is controlled by the query_
engine variable as described in the following sections.
Sub-Partition vs. Segment Parallelism
Segment parallelism differs from sub-partition parallelism in the granularity of the work done by the query threads and in the queries to which parallelism may be applied.
In sub-partition parallelism, each query thread scans a pre-computed set of sub-partitions.
Segment parallelism is preferred over sub-partition level parallelism, when possible, but segment parallelism is only applicable to simple query shapes that do not utilize the shard key.
Prior Stuff
FP is disabled by default in SingleStore in version 7.
Configure Flexible Parallelism
FP is configured with the following two engine variables:
-
sub_
: specifies the number of sub-partitions created when the database is created.to_ physical_ partition_ ratio -
query_
is a session variable that controls per session, at query time, the level of parallelism.parallelism_ per_ leaf_ core
The following table summarizes when sub-partition and segment parallelism are used.
Database State |
Types of FP Used |
||
---|---|---|---|
|
Database has sub-partitions |
Sub-partition Parallelism |
Segment Parallelism |
> 0 |
Yes |
✔ |
✔ |
> 0 |
No |
✘ |
✔ |
0 |
Not Applicable |
✘ |
✘ |
FP can be disabled for a session by setting query_
= 0.
In certain situations, queries do not use FP query_
is not 0.
Choose the Value of query_ parallelism_ per_ leaf_ core
The engine variable query_
controls the fraction of the CPU power that is dedicated to a query on each leaf node.
For example, if you want to use half of the available cores on each leaf node to process one query, set query_
to 0.
If you want to limit the parallelism to use a specific number of cores to process each query, instead of a proportion of the number of cores, you need to know the number of cores on each leaf.expected_
engine variable.
The degree of parallelism on each node is calculated as expected_
* query_
, rounded to the nearest integer.
For example, if expected_
is 28 and you want to use 10 cores on each leaf node to process a query:
-
Divide 10 by 28.
10 / 28 = 0. 35714. -
To have 10 cores processing each query, set
query_
to .parallelism_ per_ leaf_ core 35714.
Note
For high-throughput search workloads, SingleStore recommends lowering parallelism by setting query_
= .
The default setting query_
= 1 indicates a parallelism of one thread per core for each query, that is all cores are used for a query.
Check if a Database has Sub-Partitions
To determine if a database has sub-partitions, view the value of NUM_
in the DISTRIBUTED_
In these views, databases with a non-zero value in the NUM_
column have sub-partitions and sub-partition parallelism is available on those databases.
SELECT * FROM information_schema.DISTRIBUTED_DATABASES;
+-------------+---------------+----------------+--------------------+------------+-------------+---------+--------------------+-----------+---------+
| DATABASE_ID | DATABASE_NAME | NUM_PARTITIONS | NUM_SUB_PARTITIONS | CLUSTER_ID | REMOTE_NAME | IS_SYNC | IS_SYNC_DURABILITY | IS_PAUSED | SITE_ID |
+-------------+---------------+----------------+--------------------+------------+-------------+---------+--------------------+-----------+---------+
| 4 | db | 3 | 24 | 0 | | 1 | 0 | 0 | 1 |
+-------------+---------------+----------------+--------------------+------------+-------------+---------+--------------------+-----------+---------+
Check What Level of Parallelism a Query is Using
You can determine if a specific query is using FP by using EXPLAIN or PROFILE.parallelism_
for operations like Gather
, GatherMerge
, Project
, Repartition
, Broadcast
, and MaterializedCTE
.
Example output from EXPLAIN
for a SELECT *
query:
EXPLAIN SELECT * FROM example_table;
+--------------------------------------------------------------------------------------------------+
| EXPLAIN |
+--------------------------------------------------------------------------------------------------+
| Gather partitions:all alias:remote_0 parallelism_level:segment |
| Project [example_table.a, example_table.b] |
| ColumnStoreScan example_db.example_table, SORT KEY __UNORDERED () table_type:sharded_columnstore |
+--------------------------------------------------------------------------------------------------+
In this example, Gather partitions:all alias:remote_
indicates that parallelism_
is segment
for the Gather
operator in this query.
In general, the parallelism_
can be partition
, sub_
, or segment
.
-
A
parallelism_
oflevel partition
indicates one thread is used per database partition and that the query is not using FP. -
A value of
sub_
indicates sub-partition parallelism is being used.partition A value of
segment
indicates that segment parallelism is being used.
As discussed earlier, segment parallelism is preferred over sub-partition level parallelism and is used when possible.
Related Topics
For more detailed information on FP, read this blog: Flexible Parallelism in SingleStoreDB.
Last modified: June 26, 2025