The MariaDB show processlist command may be used to see a list of active queries on that UM:
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)
getActiveSQLStatements is a mcsadmin command that shows which SQL statements are currently being executed on the database:
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_name
The calGetStats function provides statistics about resources used on the User Module (UM) node, PM node, and network by the last run query. Example:
MariaDB [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)
The output contains information on:
The output is useful to determine how much physical I/O was required, how much data was cached, and how many partition blocks were eliminated through use of extent map elimination. The system maintains min / max values for each extent and uses these to help implement where clause filters to completely bypass extents where the value is outside of the min/max range. When a column is ordered (or semi-ordered) during load such as a time column this offer very large performance gains as the system can avoid scanning many extents for the column.
While the MariaDB Server's EXPLAIN utility can be used to look at the query plan, it is somewhat less helpful for ColumnStore tables as ColumnStore does not use indexes or make use of MariaDB I/O functionality. The execution plan for a query on a ColumnStore table is made up of multiple steps. Each step in the query plan performs a set of operations that are issued from the User Module to the set of Performance Modules in support of a given step in a query.
These operations are automatically executed together in order to execute appropriate filters and column lookup by row offset.
In MariaDB ColumnStore there is a set of SQL tracing stored functions provided to see the distributed query execution plan between the UM and the PM.
The basic steps to using these SQL tracing stored functions are:
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)
The columns headings in the output are as follows:
Note: The time recorded is the time from PrimProc and ExeMgr. Execution time from withing mysqld is not tracked here. There could be extra processing time in mysqld due to a number of factors such as ORDER BY.
Sometimes it can be useful to clear caches to allow understanding of uncached and cached query access. The calFlushCache() function will clear caches on all servers. This is only really useful for testing query performance:
MariaDB [test]> select calFlushCache();
It can be useful to view details about the extent map for a given column. This can be achieved using the editem process on a PM server. Available arguments can be provided by using the -h flag. The most common use is to provide the column object id with the -o argument which will output details for the column and in this case the -t argument is provided to show min / max values as dates:
/usr/local/mariadb/columnstore/bin/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
Here it can be seen that the extent maps for the o_orderdate (object id 3032) column are well partitioned since the order table source data was sorted by the order_date. This example shows 2 seperate DBRoot values as the environment was a 2 node combined deployment.
Column object ids may be found by querying the calpontsys.syscolumn metadata table (deprecated) or information_schema.columnstore_columns table (version 1.0.6+).
MariaDB ColumnStore query statistics history can be retrieved for analysis. By default the query stats collection is disabled. To enable the collection of query stats, the <QueryStats><Enabled> element in the ColumnStore.XML configuration file should be set to Y (default is N).
<QueryStats> <Enabled>Y</Enabled> </QueryStats>
Cross Engine Support must also be enabled before enabling Query Statistics. See the Cross Engine Configuration section.
When enabled the history of query statistics across all sessions along with execution time, and those stats provided by calgetstats() is stored in a table in the infinidb_querystats schema. Only queries in the following ColumnStore syntax are available for statistics monitoring:
When QueryStats is enabled, the query statistics history is collected in the querystats table in the infinidb_querystats schema.
The columns of this table are:
Users can view the query statistics by selecting the rows from the query stats table in the infinidb_querystats schema. Examples listed below:
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;
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/analyzing-queries-in-columnstore/