Examples
On this page
Finding Expensive Queries
For example, to find the five most expensive queries, run:
SELECT EXECUTION_TIME/COMMITS, QUERY_TEXT from information_schema.PLANCACHEORDER BY EXECUTION_TIME/COMMITS DESC LIMIT 5;
Finding Specific Queries
In SingleStore, the PROCESSLIST
view also has a PLAN_
column that can be used to look up the query currently running on a given connection in PLANCACHE
.
SELECT QUERY_TEXT FROM information_schema.PROCESSLISTas pl JOIN information_schema.PLANCACHEas pc ON pl.PLAN_ID = pc.PLAN_ID;
This is the most reliable way to find the query executing on a given connection.PROCESSLIST.
column is not always set by SingleStore.
Note
If you are dealing with sensitive data and want to limit access to query information, but not the full PROCESSLIST
view, this can be controlled via the variable, show_
.ON
, so query parameters will be visible in the output of SELECT
from information_
.OFF
, parameters will be hidden.
Finding the Number of Queries Running on All Databases
You can use the processlist
to get connections on the database level.
SELECT * FROM INFORMATION_
shows all the queries running on the cluster.db
, you can get the number of connections by database.
For example:
SELECT db, COUNT(*) FROM information_schema.mv_processlist WHERE db IS NOT NULL GROUP BY 1;
+--------------------+----------+
| db | COUNT(*) |
+--------------------+----------+
| information_schema | 2 |
| metrics | 2 |
+--------------------+----------+
Last modified: September 17, 2024