Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
MariaDB ColumnStore ensures high availability with multi-node setups and shared storage, while MaxScale adds monitoring and failover for continuous analytics.
MariaDB ColumnStore query tuning optimizes analytics using data types, joins, projection elimination, WHERE clauses, and EXPLAIN for performance insights.
MariaDB ColumnStore's query plans and Optimizer Trace show how analytical queries run in parallel across its distributed, columnar architecture, aiding performance tuning.
Query statistics log MariaDB ColumnStore execution metrics (memory, I/O, cache) to infinidb_querystats; disabled by default and exposed via SHOW WARNINGS and calGetStats().
sudo mcsSetConfig QueryStats Enabled YGRANT INSERT ON infinidb_querystats.querystats TO 'utility_user'@'localhost';DESCRIBE infinidb_querystats.querystatsSELECT * FROM infinidb_querystats.querystats;SELECT calGetStats();SELECT COUNT(*) FROM lineitem;+----------+
| count(*) |
+----------+
| 6001215 |
+----------+
1 row in set, 1 warning (0.039 sec)SHOW WARNINGS;Query Stats: MaxMemPct-0; NumTempFiles-0; TempFileSpace-0B; ApproxPhyI/O-0; CacheI/O-1468; BlocksTouched-1468; PartitionBlocksEliminated-0; MsgBytesIn-0B; MsgBytesOut-0B; Mode-Distributed DBroot 1ss -ntlpsource /etc/profile.d/columnstoreAlias.shsource /usr/share/columnstore/columnstoreAlias{
"timestamp": "2021-12-21 19:01:50.866654",
"172.31.22.252": {
"timestamp": "2021-12-21 19:01:50.872922",
"uptime": 361172,
"dbrm_mode": "master",
"cluster_mode": "readwrite",
"dbroots": [ "1" ],
"module_id": 1,
"services": [
{ "name": "workernode", "pid": 12292 },
{ "name": "controllernode", "pid": 12370 },
{ "name": "PrimProc", "pid": 12387 },
{ "name": "ExeMgr", "pid": 12444 },
{ "name": "WriteEngine", "pid": 12465 },
{ "name": "DMLProc", "pid": 12474 },
{ "name": "DDLProc", "pid": 12504 }
]
},
"172.31.20.34": {
"timestamp": "2021-12-21 19:01:50.958150",
"uptime": 361172,
"dbrm_mode": "slave",
"cluster_mode": "readonly",
"dbroots": [ "2" ],
"module_id": 2,
"services": [
{ "name": "workernode", "pid": 10492 },
{ "name": "PrimProc", "pid": 10513 },
{ "name": "ExeMgr", "pid": 10570 },
{ "name": "WriteEngine", "pid": 10588 }
]
},
"172.31.26.62": {
"timestamp": "2021-12-21 19:01:51.013945",
"uptime": 361174,
"dbrm_mode": "slave",
"cluster_mode": "readonly",
"dbroots": [ "3" ],
"module_id": 3,
"services": [
{ "name": "workernode", "pid": 10198 },
{ "name": "PrimProc", "pid": 10219 },
{ "name": "ExeMgr", "pid": 10276 },
{ "name": "WriteEngine", "pid": 10291 }
]
},
"num_nodes": 3
}Optimizer statistics collected with ANALYZE TABLE in MariaDB Enterprise ColumnStore 6 enable circular inner joins and help ExeMgr choose better join orders for analytical queries.
Query tuning recommendations for MariaDB ColumnStore: select only required columns, avoid large single-threaded ORDER BY and LIMIT sorts, and follow analytical best practices.
SELECT DISTINCT col1 FROM tab LIMIT 10000;SELECT DISTINCT col1 FROM tab LIMIT 100;SET SESSION columnstore_decimal_overflow_check=ON;
SELECT (big_decimal1 * big_decimal2) AS product
FROM columnstore_tab;SELECT column1, column2
FROM columnstore_tab
WHERE column1 > '2020-04-01'
AND column1 < '2020-11-01';SELECT calGetTrace();innodb_buffer_pool_size (checked via mariadb -e "show variables like '%innodb_buffer_pool_size%'")/tmp/columnstore_tmp_files/infinidb-join-data*ExeMgrSELECT calgetsqlcount();SELECT /*! INFINIDB_ORDERED */ r_regionkey
FROM region r, customer c, nation n
WHERE r.r_regionkey = n.n_regionkey
AND n.n_nationkey = c.c_nationkeyTools for inspecting active MariaDB ColumnStore queries: SHOW PROCESSLIST for the local User Module and the getActiveSQLStatements mcsadmin command for cluster-wide query state.
MariaDB [test]> SHOW PROCESSLIST;
+----+------+-----------+-------+---------+------+-------+--------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+-------+---------+------+-------+--------------+
| 73 | root | localhost | ssb10 | Query | 0 | NULL | show processlist
+----+------+-----------+-------+---------+------+-------+--------------+
1 row in set (0.01 sec)mcsadmin> getActiveSQLStatements
getactivesqlstatements Wed Oct 7 08:38:32 2015
Get List of Active SQL Statements
=================================
Start Time Time (hh:mm:ss) Session ID SQL Statement
---------------- ---------------- -------------------- ------------------------------------------------------------
Oct 7 08:38:30 00:00:03 73 select c_name,sum(lo_revenue) from customer, lineorder where lo_custkey = c_custkey and c_custkey = 6 group by c_nameMariaDB [test]> SELECT count(*) FROM wide2;
+----------+
| count(*) |
+----------+
| 5000000 |
+----------+
1 row in set (0.22 sec)
MariaDB [test]> SELECT calGetStats();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| calGetStats() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Query Stats: MaxMemPct-0; NumTempFiles-0; TempFileSpace-0B; ApproxPhyI/O-1931; CacheI/O-2446; BlocksTouched-2443; PartitionBlocksEliminated-0; MsgBytesIn-73KB; MsgBytesOut-1KB; Mode-Distributed |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)MariaDB [test]> SELECT calSetTrace(1);
+----------------+
| calSetTrace(1) |
+----------------+
| 0 |
+----------------+
1 row in set (0.00 sec)
MariaDB [test]> SELECT c_name, sum(o_totalprice)
-> FROM customer, orders
-> WHERE o_custkey = c_custkey
-> AND c_custkey = 5
-> GROUP BY c_name;
+--------------------+-------------------+
| c_name | sum(o_totalprice) |
+--------------------+-------------------+
| Customer#000000005 | 684965.28 |
+--------------------+-------------------+
1 row in set, 1 warning (0.34 sec)
MariaDB [test]> SELECT calGetTrace();
+------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------+
| calGetTrace() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------+
|
Desc Mode Table TableOID ReferencedColumns PIO LIO PBE Elapsed Rows
BPS PM customer 3024 (c_custkey,c_name) 0 43 36 0.006 1
BPS PM orders 3038 (o_custkey,o_totalprice) 0 766 0 0.032 3
HJS PM orders-customer 3038 - - - - ----- -
TAS UM - - - - - - 0.021 1
|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)MariaDB [test]> SELECT calFlushCache();editem -o 3032 -t
Col OID = 3032, NumExtents = 10, width = 4
428032 - 432127 (4096) min: 1992-01-01, max: 1993-06-21, seqNum: 1, state: valid, fbo: 0, DBRoot: 1, part#: 0, seg#: 0, HWM: 0; status: avail
502784 - 506879 (4096) min: 1992-01-01, max: 1993-06-22, seqNum: 1, state: valid, fbo: 0, DBRoot: 2, part#: 0, seg#: 1, HWM: 0; status: unavail
708608 - 712703 (4096) min: 1993-06-21, max: 1994-12-11, seqNum: 1, state: valid, fbo: 0, DBRoot: 1, part#: 0, seg#: 2, HWM: 0; status: unavail
766976 - 771071 (4096) min: 1993-06-22, max: 1994-12-12, seqNum: 1, state: valid, fbo: 0, DBRoot: 2, part#: 0, seg#: 3, HWM: 0; status: unavail
989184 - 993279 (4096) min: 1994-12-11, max: 1996-06-01, seqNum: 1, state: valid, fbo: 4096, DBRoot: 1, part#: 0, seg#: 0, HWM: 8191; status: avail
1039360 - 1043455 (4096) min: 1994-12-12, max: 1996-06-02, seqNum: 1, state: valid, fbo: 4096, DBRoot: 2, part#: 0, seg#: 1, HWM: 8191; status: avail
1220608 - 1224703 (4096) min: 1996-06-01, max: 1997-11-22, seqNum: 1, state: valid, fbo: 4096, DBRoot: 1, part#: 0, seg#: 2, HWM: 8191; status: avail
1270784 - 1274879 (4096) min: 1996-06-02, max: 1997-11-22, seqNum: 1, state: valid, fbo: 4096, DBRoot: 2, part#: 0, seg#: 3, HWM: 8191; status: avail
1452032 - 1456127 (4096) min: 1997-11-22, max: 1998-08-02, seqNum: 1, state: valid, fbo: 0, DBRoot: 1, part#: 1, seg#: 0, HWM: 1930; status: avail
1510400 - 1514495 (4096) min: 1997-11-22, max: 1998-08-02, seqNum: 1, state: valid, fbo: 0, DBRoot: 2, part#: 1, seg#: 1, HWM: 1930; status: avail<QueryStats>
<Enabled>Y</Enabled>
</QueryStats>grant INSERT on infinidb_querystats.querystats to 'cross_engine'@'127.0.0.1';
grant INSERT on infinidb_querystats.querystats to 'cross_engine'@'localhost';MariaDB [infinidb_querystats]> select queryid, query, endtime-starttime, rows from querystats
where starttime >= now() - interval 12 hour and querytype = 'SELECT';MariaDB [infinidb_querystats]> select a.* from (select endtime-starttime execTime, query from queryStats
where sessionid = 2 and querytype = 'SELECT' and starttime >= now()-interval 12 hour
order by 1 limit 3) a;MariaDB [infinidb_querystats]> select min(endtime-starttime), max(endtime-starttime), avg(endtime-starttime) from querystats
where querytype='INSERT SELECT' and starttime >= now() - interval 12 hour;SELECT * FROM information_schema.columnstore_columns WHERE table_name='your_table' AND column_name='your_column';SELECT * FROM information_schema.columnstore_extents WHERE object_id=[OID];CREATE TABLE your_table_ordered LIKE your_table;INSERT INTO your_table_ordered SELECT * FROM your_table WHERE your_column=0;
INSERT INTO your_table_ordered SELECT * FROM your_table WHERE your_column=1;
-- Continue iteratively for all ranges