From c153336199bf3e46001d7e30341974d4de158ee6 Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Thu, 10 Aug 2017 16:23:04 +0200 Subject: [PATCH 1/8] Add 1.1 page for SHOW SESSIONS statement --- v1.1/show-sessions.md | 162 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 v1.1/show-sessions.md diff --git a/v1.1/show-sessions.md b/v1.1/show-sessions.md new file mode 100644 index 00000000000..f828e5f6c72 --- /dev/null +++ b/v1.1/show-sessions.md @@ -0,0 +1,162 @@ +--- +title: SHOW SESSIONS +summary: The SHOW SESSIONS statement lists all currently active sessions across the cluster or on the local node. +toc: false +--- + +New in v1.1: The `SHOW SESSIONS` [statement](sql-statements.html) lists details about currently active sessions, including: + +- The address of the client that opened the session +- The node connected to +- How long the connection has been open +- Which queries are active in the session +- Which query has been running longest in the session + +These details let you monitor the overall state of client connections and identify those that may need further investigation or adjustment. + +
+ +## Required Privileges + +No [privileges](privileges.html) are required to execute this statement. However, note that non-`root` users see only their own currently active sessions, wherease the `root` user sees all users' currently active sessions. + +## Synopsis + +{% include sql/{{ page.version.version }}/diagrams/show_sessions.html %} + +- To list the active sessions across all nodes of the cluster, use `SHOW SESSIONS` or `SHOW CLUSTER SESSIONS`. +- To list the active sessions just on the local node, use `SHOW LOCAL SESSIONS`. + +## Response + +The following fields are returned for each session: + +Field | Description +------|------------ +`node_id` | The ID of the node connected to. +`username` | The username of the connected user. +`client_address` | The address and port of the connected client. +`application_name` | The [application name](set-vars.html#supported-variables) specified by the client, if any. +`active_queries` | The SQL queries currently active in the session. +`last_active_query` | The most recently completed SQL query in the session. +`session_start` | The timestamp at which the session started. +`oldest_query_start` | The timestamp at which the oldest currently active SQL query in the session started. +`kv_txn` | The ID of the current key-value transaction for the session. + +## Examples + +### List Active Sessions Across the Cluster + +~~~ sql +> SHOW CLUSTER SESSIONS; +~~~ + +~~~ ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------|----------------------------------+----------------------------------+--------------------------------------+ +| node_id | username | client_address | application_name | active_queries | last_active_query | session_start | oldest_query_start | kv_txn | ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------+----------------------------------+----------------------------------+--------------------------------------| +| 2 | mroach | 192.168.0.72:56194 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878113+00:00 | 2017-08-10 14:08:44.648985+00:00 | 81fbdd4d-394c-4784-b540-97cd73910dba | +| 2 | mroach | 192.168.0.72:56201 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878306+00:00 | 2017-08-10 14:08:44.653135+00:00 | 5aa6f141-5cae-468f-b16a-dfe8d4fb4bea | +| 2 | mroach | 192.168.0.72:56198 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878464+00:00 | 2017-08-10 14:08:44.643749+00:00 | d8fedb88-fc21-4720-aabe-cd43ec204d88 | +| 3 | broach | 192.168.0.73:56199 | test_app | SELECT k, v FROM test.kv WHERE k = $1; | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | 2017-08-10 14:08:22.878048+00:00 | 2017-08-10 14:08:44.655709+00:00 | NULL | +| 3 | broach | 192.168.0.73:56196 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878166+00:00 | 2017-08-10 14:08:44.647464+00:00 | aded7717-94e1-4ac4-9d37-8765e3418e32 | +| 1 | lroach | 192.168.0.71:56180 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.87337+00:00 | 2017-08-10 14:08:44.64788+00:00 | f691c5dd-b29e-48ed-a1dd-6d7f71faa82e | +| 1 | lroach | 192.168.0.71:56197 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.877932+00:00 | 2017-08-10 14:08:44.644786+00:00 | 86ae25ea-9abf-4f5e-ad96-0522178f4ce6 | +| 1 | lroach | 192.168.0.71:56200 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878534+00:00 | 2017-08-10 14:08:44.653524+00:00 | 8ad972b6-4347-4128-9e52-8553f3491963 | +| 1 | root | 127.0.0.1:56211 | | SHOW CLUSTER SESSIONS; | | 2017-08-10 14:08:27.666826+00:00 | 2017-08-10 14:08:44.653355+00:00 | NULL | ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------+----------------------------------+----------------------------------|--------------------------------------+ +(9 rows) +~~~ + +Alternatively, you can use `SHOW SESSIONS` to receive the same response. + +### List Active Sessions on the Local Node + +~~~ sql +> SHOW LOCAL SESSIONS; +~~~ + +~~~ ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------|----------------------------------+----------------------------------+--------------------------------------+ +| node_id | username | client_address | application_name | active_queries | last_active_query | session_start | oldest_query_start | kv_txn | ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------+----------------------------------+----------------------------------+--------------------------------------| +| 1 | lroach | 192.168.0.71:56180 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.87337+00:00 | 2017-08-10 14:08:44.64788+00:00 | f691c5dd-b29e-48ed-a1dd-6d7f71faa82e | +| 1 | lroach | 192.168.0.71:56197 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.877932+00:00 | 2017-08-10 14:08:44.644786+00:00 | 86ae25ea-9abf-4f5e-ad96-0522178f4ce6 | +| 1 | lroach | 192.168.0.71:56200 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878534+00:00 | 2017-08-10 14:08:44.653524+00:00 | 8ad972b6-4347-4128-9e52-8553f3491963 | +| 1 | root | 127.0.0.1:56211 | | SHOW CLUSTER SESSIONS; | | 2017-08-10 14:08:27.666826+00:00 | 2017-08-10 14:08:44.653355+00:00 | NULL | ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------+----------------------------------+----------------------------------|--------------------------------------+ +(4 rows) +~~~ + +### Filter for Specific Sessions + +You can use a [`SELECT`](select.html) statement to filter the list of currently active sessions by one or more of the [response fields](#response). + +For example, the following query filters for sessions where the connected user is `mroach`: + +~~~ sql +> SELECT * FROM [SHOW CLUSTER SESSIONS] WHERE username = 'mroach'; +~~~ + +~~~ ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------|----------------------------------+----------------------------------+--------------------------------------+ +| node_id | username | client_address | application_name | active_queries | last_active_query | session_start | oldest_query_start | kv_txn | ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------+----------------------------------+----------------------------------+--------------------------------------| +| 2 | mroach | 192.168.0.72:56194 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878113+00:00 | 2017-08-10 14:08:44.648985+00:00 | 81fbdd4d-394c-4784-b540-97cd73910dba | +| 2 | mroach | 192.168.0.72:56201 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878306+00:00 | 2017-08-10 14:08:44.653135+00:00 | 5aa6f141-5cae-468f-b16a-dfe8d4fb4bea | +| 2 | mroach | 192.168.0.72:56198 | test_app | UPSERT INTO test.kv(k, v) VALUES ($1, $2); | SELECT k, v FROM test.kv WHERE k = $1; | 2017-08-10 14:08:22.878464+00:00 | 2017-08-10 14:08:44.643749+00:00 | d8fedb88-fc21-4720-aabe-cd43ec204d88 | ++---------+----------+--------------------+------------------+---------------------------------------------+--------------------------------------------+----------------------------------+----------------------------------|--------------------------------------+ +(3 rows) +~~~ + +### Identify and Cancel a Problematic Query + +If a session has been open for a long time and you are concerned that the oldest active SQL query may be problematic, you can use the [`SHOW QUERIES`](show-queries.html) statement to further investigate the query and then, if necessary, use the [`CANCEL QUERY`](cancel-query.html) statement to cancel it. + +For example, let's say you run `SHOW SESSIONS` and notice that the following session has been open for more than 2 hours: + +~~~ ++---------+----------+--------------------+------------------+------------------------------------+--------------------|----------------------------------+----------------------------------+--------+ +| node_id | username | client_address | application_name | active_queries | last_active_query | session_start | oldest_query_start | kv_txn | ++---------+----------+--------------------+------------------+------------------------------------+--------------------+----------------------------------+----------------------------------|--------+ +| 2 | mroach | 192.168.0.72:56194 | test_app | SELECT * FROM test.kv ORDER BY k; | | 2017-08-10 14:08:22.878113+00:00 | 2017-08-10 14:08:22.878113+00:00 | NULL | ++---------+----------+--------------------+------------------+------------------------------------+--------------------|----------------------------------+----------------------------------+--------+ +~~~ + +Since the `oldest_query_start` timestamp is the same as the `session_start` timestamp, you are concerned that the `SELECT` query shown in `active_queries` has been running for too long and may be consuming too many resources. So you use the [`SHOW QUERIES`](show-queries.html) statement to get more information about the query, filtering based on details you already have: + +~~~ sql +> SELECT * FROM [SHOW CLUSTER QUERIES] + WHERE client_address = '192.168.0.72:56194' + AND username = 'mroach' + AND query = 'SELECT * FROM test.kv ORDER BY k'; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| 14dacc1f9a781e3d0000000000000001 | 2 | mroach | 2017-08-10 14:08:22.878113+00:00 | SELECT * FROM test.kv ORDER BY k | 192.168.0.72:56194 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +~~~ + +Using the `start` field, you confirm that the query has been running since the start of the session and decide that is too long. So to cancel the query, and stop it from consuming resources, you note the `query_id` and use it with the [`CANCEL QUERY`](cancel-query.html) statement: + +~~~ sql +> CANCEL QUERY '14dacc1f9a781e3d0000000000000001'; +~~~ + +Alternatively, if you know that you want to cancel the query based on the details in `SHOW SESSIONS`, you could execute a single [`CANCEL QUERY`](cancel-query.html) statement with a nested `SELECT` statement that returns the `query_id`: + +~~~ sql +> CANCEL QUERY (SELECT query_id FROM [SHOW CLUSTER QUERIES] + WHERE client_address = '192.168.0.72:56194' + AND username = 'mroach' + AND query = 'SELECT * FROM test.kv ORDER BY k'); +~~~ + +## See Also + +- [`SHOW QUERIES`](show-queries.html) +- [`CANCEL QUERY`](cancel-query.html) +- [Other SQL Statements](sql-statements.html) From b4f13a05d2dce41a78401613b702cd9c67ed7ae7 Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Thu, 10 Aug 2017 16:23:14 +0200 Subject: [PATCH 2/8] Add 1.1 page for SHOW QUERIES statement --- v1.1/show-queries.md | 177 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 v1.1/show-queries.md diff --git a/v1.1/show-queries.md b/v1.1/show-queries.md new file mode 100644 index 00000000000..6f598af53d9 --- /dev/null +++ b/v1.1/show-queries.md @@ -0,0 +1,177 @@ +--- +title: SHOW QUERIES +summary: The SHOW QUERIES statement lists all currently active queries across the cluster or on the local node. +toc: false +--- + +New in v1.1: The `SHOW QUERIES` [statement](sql-statements.html) lists details about currently active SQL queries, including: + +- The internal ID of the query +- The node executing the query +- The SQL query itself +- How long the query has been running +- The client address, application name, and user that issued the query + +These details let you monitor the progress of active queries and, if necessary, identify those that may need to be [cancelled](cancel-query.html) to prevent unwanted resource consumption. + +{{site.data.alerts.callout_info}}Schema changes and BACKUP/RESTORE statements are not executed as queries internally and so are not listed by SHOW QUERIES. To monitor such statements, use SHOW JOBS instead.{{site.data.alerts.end}} + +
+ +## Required Privileges + +No [privileges](privileges.html) are required to execute this statement. However, note that non-`root` users see only their own currently active queries, whereas the `root` user sees all users' currently active queries. + +## Synopsis + +{% include sql/{{ page.version.version }}/diagrams/show_queries.html %} + +- To list the active queries across all nodes of the cluster, use `SHOW QUERIES` or `SHOW CLUSTER QUERIES`. +- To list the active queries just on the local node, use `SHOW LOCAL QUERIES`. + +## Response + +The following fields are returned for each query: + +Field | Description +------|------------ +`query_id` | The ID of the query. +`node_id` | The ID of the node connected to. +`username` | The username of the connected user. +`start` | The timestamp at which the query started. +`query` | The SQL query. +`client_address` | The address and port of the client that issued the SQL query. +`application_name` | The [application name](set-vars.html#supported-variables) specified by the client, if any. +`distributed` | If `true`, the query is being executed by the Distributed SQL (DistSQL) engine. If `false`, the query is being executed by the standard "local" SQL engine. If `NULL`, the query is being prepared and it's not yet known which execution engine will be used. +`phase` | The phase of the query's execution. If `preparing`, the statement is being parsed and planned. If `executing`, the statement is being executed. + +## Examples + +### List Queries Across the Cluster + +~~~ sql +> SHOW CLUSTER QUERIES; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| 14db657443230c3e0000000000000001 | 1 | root | 2017-08-16 18:00:50.675151+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54119 | test_app | false | executing | +| 14db657443b68c7d0000000000000001 | 1 | root | 2017-08-16 18:00:50.684818+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54123 | test_app | false | executing | +| 14db65744382c2340000000000000001 | 1 | root | 2017-08-16 18:00:50.681431+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54103 | test_app | false | executing | +| 14db657443c9dc660000000000000001 | 1 | root | 2017-08-16 18:00:50.686083+00:00 | SHOW CLUSTER QUERIES | 192.168.12.56:54108 | | NULL | preparing | +| 14db657443e30a850000000000000003 | 3 | root | 2017-08-16 18:00:50.68774+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.58:54118 | test_app | false | executing | +| 14db6574439f477d0000000000000003 | 3 | root | 2017-08-16 18:00:50.6833+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.58:54122 | test_app | false | executing | +| 14db6574435817d20000000000000002 | 2 | root | 2017-08-16 18:00:50.678629+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54121 | test_app | false | executing | +| 14db6574433c621f0000000000000002 | 2 | root | 2017-08-16 18:00:50.676813+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54124 | test_app | false | executing | +| 14db6574436f71d50000000000000002 | 2 | root | 2017-08-16 18:00:50.680165+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54117 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +(9 rows) +~~~ + +Alternatively, you can use `SHOW QUERIES` to receive the same response. + +### List Queries on the Local Node + +~~~ sql +> SHOW LOCAL QUERIES; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| 14db657cd9005cb90000000000000001 | 1 | root | 2017-08-16 18:01:27.5492+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54103 | test_app | false | executing | +| 14db657cd8d7d9a50000000000000001 | 1 | root | 2017-08-16 18:01:27.546538+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54119 | test_app | false | executing | +| 14db657cd8e966c40000000000000001 | 1 | root | 2017-08-16 18:01:27.547696+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54123 | test_app | false | executing | +| 14db657cd92ad8f80000000000000001 | 1 | root | 2017-08-16 18:01:27.551986+00:00 | SHOW LOCAL QUERIES | 192.168.12.56:54122 | | NULL | preparing | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +(4 rows) +~~~ + +### Filter for Specific Queries + +You can use a [`SELECT`](select.html) statement to filter the list of active queries by one or more of the [response fields](#response). + +#### Show all queries on node 2 + +~~~ sql +> SELECT * FROM [SHOW CLUSTER QUERIES] + WHERE node_id = 2; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| 14db6574435817d20000000000000002 | 2 | root | 2017-08-16 18:00:50.678629+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54121 | test_app | false | executing | +| 14db6574433c621f0000000000000002 | 2 | root | 2017-08-16 18:00:50.676813+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54124 | test_app | false | executing | +| 14db6574436f71d50000000000000002 | 2 | root | 2017-08-16 18:00:50.680165+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54117 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +(3 rows) +~~~ + +#### Show all queries that have been running for more than 3 hours + +~~~ sql +> SELECT * FROM [SHOW CLUSTER QUERIES] + WHERE start < (now() - INTERVAL '3 hours'); +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| 14dacc1f9a781e3d0000000000000001 | 2 | mroach | 2017-08-10 11:34:32.778412+00:00 | SELECT * FROM test.kv ORDER BY k | 192.168.0.72:56194 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +~~~ + +#### Show all queries from a specific address and user + +~~~ sql +> SELECT * FROM [SHOW CLUSTER QUERIES] + WHERE client_address = '192.168.0.72:56194' + AND username = 'mroach'; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| 14dacc1f9a781e3d0000000000000001 | 2 | mroach | 2017-08-10 14:08:22.878113+00:00 | SELECT * FROM test.kv ORDER BY k | 192.168.0.72:56194 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +~~~ + +### Cancel a Query + +When you see a query that is taking too long to complete, you can use the [`CANCEL QUERY`](cancel-query.html) statement to kill it. + +For example, let's say you use `SHOW CLUSTER QUERIES` to find queries that have been running for more than 3 hours: + +~~~ sql +> SELECT * FROM [SHOW CLUSTER QUERIES] + WHERE start < (now() - INTERVAL '3 hours'); +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| 14dacc1f9a781e3d0000000000000001 | 2 | mroach | 2017-08-10 11:34:32.778412+00:00 | SELECT * FROM test.kv ORDER BY k | 192.168.0.72:56194 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +~~~ + +To cancel this long-running query, and stop it from consuming resources, you note the `query_id` and use it with the `CANCEL QUERY` statement: + +~~~ sql +> CANCEL QUERY '14dacc1f9a781e3d0000000000000001'; +~~~ + +## See Also + +- [Manage Long-Running Queries](manage-long-running-queries.html) +- [`CANCEL QUERY`](cancel-query.html) +- [`SHOW SESSIONS`](show-sessions.html) +- [`SHOW JOBS`](show-jobs.html) +- [Other SQL Statements](sql-statements.html) From 64e69c47bee63a3f68112cef3441f394a91d44ae Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Mon, 14 Aug 2017 17:31:48 -0400 Subject: [PATCH 3/8] Generate sql diagrams --- _includes/sql/v1.1/diagrams/cancel_query.html | 19 ++++++++++++++++++ _includes/sql/v1.1/diagrams/show_queries.html | 20 +++++++++++++++++++ .../sql/v1.1/diagrams/show_sessions.html | 20 +++++++++++++++++++ generate/main.go | 4 +++- 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 _includes/sql/v1.1/diagrams/cancel_query.html create mode 100644 _includes/sql/v1.1/diagrams/show_queries.html create mode 100644 _includes/sql/v1.1/diagrams/show_sessions.html diff --git a/_includes/sql/v1.1/diagrams/cancel_query.html b/_includes/sql/v1.1/diagrams/cancel_query.html new file mode 100644 index 00000000000..6cc33a38466 --- /dev/null +++ b/_includes/sql/v1.1/diagrams/cancel_query.html @@ -0,0 +1,19 @@ +
+ + + + + + CANCEL + + + QUERY + + + + query_id + + + + +
\ No newline at end of file diff --git a/_includes/sql/v1.1/diagrams/show_queries.html b/_includes/sql/v1.1/diagrams/show_queries.html new file mode 100644 index 00000000000..26376243dac --- /dev/null +++ b/_includes/sql/v1.1/diagrams/show_queries.html @@ -0,0 +1,20 @@ +
+ + + + + + SHOW + + + CLUSTER + + + LOCAL + + + QUERIES + + + +
\ No newline at end of file diff --git a/_includes/sql/v1.1/diagrams/show_sessions.html b/_includes/sql/v1.1/diagrams/show_sessions.html new file mode 100644 index 00000000000..3b2aa5b16ee --- /dev/null +++ b/_includes/sql/v1.1/diagrams/show_sessions.html @@ -0,0 +1,20 @@ +
+ + + + + + SHOW + + + CLUSTER + + + LOCAL + + + SESSIONS + + + +
\ No newline at end of file diff --git a/generate/main.go b/generate/main.go index eeb1b128adb..cdfeec08127 100644 --- a/generate/main.go +++ b/generate/main.go @@ -281,7 +281,7 @@ func main() { inline: []string{"opt_transaction"}, match: []*regexp.Regexp{regexp.MustCompile("'COMMIT'|'END'")}, }, - {name: "cancel", stmt: "cancel_query_stmt"}, + {name: "cancel_query", stmt: "cancel_query_stmt", replace: map[string]string{"a_expr": "query_id"}, unlink: []string{"query_id"}}, {name: "create_database_stmt", inline: []string{"opt_encoding_clause"}, replace: map[string]string{"'SCONST'": "encoding"}, unlink: []string{"name", "encoding"}}, { name: "create_index_stmt", @@ -532,6 +532,8 @@ func main() { }, {name: "show_index", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'INDEX'")}, replace: map[string]string{"var_name": "table_name"}, unlink: []string{"table_name"}}, {name: "show_keys", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'KEYS'")}}, + {name: "show_queries", stmt: "show_queries_stmt"}, + {name: "show_sessions", stmt: "show_sessions_stmt"}, {name: "show_tables", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'TABLES'")}}, {name: "show_transaction", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'TRANSACTION'")}}, {name: "show_users", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'USERS'")}}, From 2f9311110af89e33ad1efd60305d26515400c9e7 Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Mon, 14 Aug 2017 23:35:13 -0400 Subject: [PATCH 4/8] Add statements to 1.1 sidenav --- _includes/sidebar-data-v1.1.json | 34 ++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/_includes/sidebar-data-v1.1.json b/_includes/sidebar-data-v1.1.json index 6e62a5f1524..c7ad9ed0bd6 100644 --- a/_includes/sidebar-data-v1.1.json +++ b/_includes/sidebar-data-v1.1.json @@ -444,6 +444,18 @@ "/${VERSION}/show-index.html" ] }, + { + "title": "SHOW QUERIES", + "urls": [ + "/${VERSION}/show-queries.html" + ] + }, + { + "title": "SHOW SESSIONS", + "urls": [ + "/${VERSION}/show-sessions.html" + ] + }, { "title": "SHOW TABLES", "urls": [ @@ -852,15 +864,9 @@ ] }, { - "title": "View Node Details", - "urls": [ - "/${VERSION}/view-node-details.html" - ] - }, - { - "title": "View Version Details", + "title": "Manage Long-Running Queries", "urls": [ - "/${VERSION}/view-version-details.html" + "/${VERSION}/manage-long-running-queries.html" ] }, { @@ -899,6 +905,18 @@ "/${VERSION}/generate-cockroachdb-resources.html" ] }, + { + "title": "View Node Details", + "urls": [ + "/${VERSION}/view-node-details.html" + ] + }, + { + "title": "View Version Details", + "urls": [ + "/${VERSION}/view-version-details.html" + ] + }, { "title": "Diagnostics Reporting", "urls": [ From f98649a7b7bcf64f72d291f1546d25f74ae0f26e Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Wed, 16 Aug 2017 11:48:27 -0400 Subject: [PATCH 5/8] Add statements to 1.1 sql statements overview --- v1.1/sql-statements.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/v1.1/sql-statements.md b/v1.1/sql-statements.md index 052c5a5763e..6935ee22cb5 100644 --- a/v1.1/sql-statements.md +++ b/v1.1/sql-statements.md @@ -87,7 +87,10 @@ Statement | Usage Statement | Usage ----------|------------ +[`CANCEL QUERY`](cancel-query.html) | Cancel a running SQL query. [`SHOW ALL CLUSTER SETTINGS`](cluster-settings.html#view-current-cluster-settings) | List the current cluster-wide settings. +[`SHOW SESSIONS`](show-sessions.html) | List details about currently active sessions. +[`SHOW QUERIES`](show-queries.html) | List details about current active SQL queries. [`SET CLUSTER SETTING`](cluster-settings.html#change-a-cluster-setting) | Set a cluster-wide setting. ## Backup & Restore Statements (Enterprise) From 55c08f3ecc1880429a77f8c697d5320380e92f58 Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Thu, 17 Aug 2017 14:54:27 -0400 Subject: [PATCH 6/8] Add 1.1 page and diagram for SHOW JOBS --- _includes/sql/v1.1/diagrams/show_jobs.html | 14 ++++++++ generate/main.go | 1 + v1.1/show-jobs.md | 38 ++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 _includes/sql/v1.1/diagrams/show_jobs.html create mode 100644 v1.1/show-jobs.md diff --git a/_includes/sql/v1.1/diagrams/show_jobs.html b/_includes/sql/v1.1/diagrams/show_jobs.html new file mode 100644 index 00000000000..b59d4d176d0 --- /dev/null +++ b/_includes/sql/v1.1/diagrams/show_jobs.html @@ -0,0 +1,14 @@ +
+ + + + + + SHOW + + + JOBS + + + +
\ No newline at end of file diff --git a/generate/main.go b/generate/main.go index cdfeec08127..07fc129a654 100644 --- a/generate/main.go +++ b/generate/main.go @@ -531,6 +531,7 @@ func main() { unlink: []string{"table_name", "database_name", "user_name"}, }, {name: "show_index", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'INDEX'")}, replace: map[string]string{"var_name": "table_name"}, unlink: []string{"table_name"}}, + {name: "show_jobs", stmt: "show_jobs_stmt"}, {name: "show_keys", stmt: "show_stmt", match: []*regexp.Regexp{regexp.MustCompile("'SHOW' 'KEYS'")}}, {name: "show_queries", stmt: "show_queries_stmt"}, {name: "show_sessions", stmt: "show_sessions_stmt"}, diff --git a/v1.1/show-jobs.md b/v1.1/show-jobs.md new file mode 100644 index 00000000000..e7b9cac4762 --- /dev/null +++ b/v1.1/show-jobs.md @@ -0,0 +1,38 @@ +--- +title: SHOW JOBS +summary: The SHOW JOBS statement lists all currently active schema changes and backup/restore jobs. +toc: false +--- + +New in v1.1: The `SHOW JOBS` [statement](sql-statements.html) lists details about currently active schema changes and backup/restore jobs, including: + +- xx +- xx +- xx + +These details let you... + +
+ +## Required Privileges + +XX + +## Synopsis + +{% include sql/{{ page.version.version }}/diagrams/show_jobs.html %} + +## Response + +The following fields are returned for each session: + +Field | Description +------|------------ + +## Examples + +XX + +## See Also + +XX From 94ee5996e5c6ade3bdea67a70a5d7c4477dca0eb Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Mon, 21 Aug 2017 15:42:49 -0400 Subject: [PATCH 7/8] 1.1 documentation for CANCEL QUERY --- _includes/sidebar-data-v1.1.json | 6 +++ v1.1/cancel-query.md | 63 ++++++++++++++++++++++++++++---- v1.1/sql-statements.md | 2 +- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/_includes/sidebar-data-v1.1.json b/_includes/sidebar-data-v1.1.json index c7ad9ed0bd6..fde8b44c641 100644 --- a/_includes/sidebar-data-v1.1.json +++ b/_includes/sidebar-data-v1.1.json @@ -210,6 +210,12 @@ "/${VERSION}/begin-transaction.html" ] }, + { + "title": "CANCEL QUERY", + "urls": [ + "/${VERSION}/cancel-query.html" + ] + }, { "title": "COMMIT", "urls": [ diff --git a/v1.1/cancel-query.md b/v1.1/cancel-query.md index 989c19eb0ac..4d61bc97ebe 100644 --- a/v1.1/cancel-query.md +++ b/v1.1/cancel-query.md @@ -1,29 +1,76 @@ --- title: CANCEL QUERY -summary: Cancel a running query +summary: The CANCEL QUERY statement cancels a running SQL query. toc: false --- -The `CANCEL QUERY` [statement](sql-statements.html) cancels a running query. - -{{site.data.alerts.callout_danger}}Documentation coming soon.{{site.data.alerts.end}} +New in v1.1: The `CANCEL QUERY` [statement](sql-statements.html) cancels a running SQL query.
-## Synopsis +## Considerations -{% include sql/{{ page.version.version }}/diagrams/cancel.html %} +- Schema changes (statements beginning with ALTER) cannot currently be cancelled. However, to monitor the progress of schema changes, you can use SHOW JOBS. +- In rare cases where a query is close to completion when a cancellation request is issued, the query may run to competion. ## Required Privileges -`root` can cancel any query running on the cluster. +The `root` user can cancel any currently active queries, whereas non-`root` users cancel only their own currently active queries. + +## Synopsis -Other users can cancel only queries they executed. +{% include sql/{{ page.version.version }}/diagrams/cancel_query.html %} ## Parameters +Parameter | Description +----------|------------ +`query_id` | The ID of the query to cancel, or a [`SELECT`](select.html) statement that returns the ID of the query to cancel. + +## Response + +When a query is successfully cancelled, CockoachDB sends a `query execution canceled` error to the client that issued the query. + +- If the canceled query was a single, standalone statement, no further action is required by the client. +- If the canceled query was part of a larger, multi-statement [transaction](transactions.html), the client should then issue a [`ROLLBACK`](rollback-transaction.html) statement. + ## Examples +### Cancel a Query via the Query ID + +In this example, we use the [`SHOW QUERIES`](show-queries.html) statement to get the ID of a query and then pass the ID into the `CANCEL QUERY` statement: + +~~~ sql +> SHOW QUERIES; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| 14dacc1f9a781e3d0000000000000001 | 2 | mroach | 2017-08-10 14:08:22.878113+00:00 | SELECT * FROM test.kv ORDER BY k | 192.168.0.72:56194 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +| 14dacc206c47a9690000000000000002 | 2 | root | 2017-08-14 19:11:05.309119+00:00 | SHOW CLUSTER QUERIES | 127.0.0.1:50921 | | NULL | preparing | ++----------------------------------+---------+----------+----------------------------------+----------------------------------+--------------------+------------------+-------------+-----------+ +~~~ + +~~~ sql +> CANCEL QUERY '14dacc1f9a781e3d0000000000000001'; +~~~ + +### Cancel a Query via a Nested `SELECT` Statement + +In this example, we nest a [`SELECT`](select.html) statement that retrieves the ID of a query inside the `CANCEL QUERY` statement: + +~~~ sql +> CANCEL QUERY (SELECT query_id FROM [SHOW CLUSTER QUERIES] + WHERE client_address = '192.168.0.72:56194' + AND username = 'mroach' + AND query = 'SELECT * FROM test.kv ORDER BY k'); +~~~ + ## See Also +- [Manage Long-Running Queries](manage-long-running-queries.html) +- [`SHOW QUERIES`](show-queries.html) - [SQL Statements](sql-statements.html) diff --git a/v1.1/sql-statements.md b/v1.1/sql-statements.md index 6935ee22cb5..70dd541147b 100644 --- a/v1.1/sql-statements.md +++ b/v1.1/sql-statements.md @@ -88,10 +88,10 @@ Statement | Usage Statement | Usage ----------|------------ [`CANCEL QUERY`](cancel-query.html) | Cancel a running SQL query. +[`SET CLUSTER SETTING`](cluster-settings.html#change-a-cluster-setting) | Set a cluster-wide setting. [`SHOW ALL CLUSTER SETTINGS`](cluster-settings.html#view-current-cluster-settings) | List the current cluster-wide settings. [`SHOW SESSIONS`](show-sessions.html) | List details about currently active sessions. [`SHOW QUERIES`](show-queries.html) | List details about current active SQL queries. -[`SET CLUSTER SETTING`](cluster-settings.html#change-a-cluster-setting) | Set a cluster-wide setting. ## Backup & Restore Statements (Enterprise) From 93b5eb769c385d245e17be210e63ad5073f0ebf9 Mon Sep 17 00:00:00 2001 From: Jesse Seldess Date: Mon, 21 Aug 2017 17:10:50 -0400 Subject: [PATCH 8/8] Add 1.1 page on managing long-running queries Also update query performance troubleshooting page to link to new page, and remove details about query logging (for now). --- v1.1/debug-and-error-logs.md | 52 ------------------- v1.1/manage-long-running-queries.md | 69 ++++++++++++++++++++++++++ v1.1/query-behavior-troubleshooting.md | 8 +-- 3 files changed, 73 insertions(+), 56 deletions(-) create mode 100644 v1.1/manage-long-running-queries.md diff --git a/v1.1/debug-and-error-logs.md b/v1.1/debug-and-error-logs.md index e990b31cb8a..98fd13612a1 100644 --- a/v1.1/debug-and-error-logs.md +++ b/v1.1/debug-and-error-logs.md @@ -16,8 +16,6 @@ As a command generates messages, CockroachDB uses the [command](#commands)'s [lo Each node's logs detail only the internal activity of that node without visibility into the behavior of other nodes in the cluster. When troubleshooting, this means that you must identify the node where the problem occurred or [collect the logs from all active nodes in your cluster](debug-zip.html). -{{site.data.alerts.callout_info}}You can also log queries your cluster receives.{{site.data.alerts.end}} - ### Commands All [`cockroach` commands](cockroach-commands.html) support logging. However, it's important to note: @@ -93,56 +91,6 @@ By default, commands besides `cockroach start` discard messages with the `INFO` The `--log-backtrace-at`, `--verbosity`, and `--v` flags are intended for internal debugging by CockroachDB contributors. -## Log Queries - -To help troubleshoot [query performance issues](query-behavior-troubleshooting.html#performance-issues), you can use [cluster-wide settings](cluster-settings.html) to enable logging for long-running SQL transactions or all queries, regardless of time. - -{{site.data.alerts.callout_danger}}These settings makes all queries slower and causes nodes to consume more memory. You should disable query logging as soon as you're done troubleshooting the query's issues.{{site.data.alerts.end}} - -### Enable Query Logging - -- **Long-running transactions**: - - ~~~ sql - > SET CLUSTER SETTING sql.trace.txn.enable_threshold = '[time]'; - ~~~ - - The `[time]` parameter accepts common time specifiers, such as `100ms` or `2s`. - -- **All queries**: - - ~~~ sql - > SET CLUSTER SETTING sql.trace.log_statement_execute = true; - ~~~ - -### Details - -After you enable query logging, whenever nodes process SQL statements, they generate messages with an `INFO` [severity level](#severity-levels). - -By default, these messages will get [written to files](#write-to-file), but are ultimate handled by whatever logging behavior you set for [`cockroach start`](start-a-node.html#logging). - -### Improve Query Performance - -After finding which queries are slow, use [`EXPLAIN`](explain.html) to examine them. It's possible that the query is slow because it performs a full-table scan. In these cases, you can likely improve the query's performance by [adding an index](create-index.html). - -*(More guidance around query performance optimization forthcoming.)* - -### Disable Query Logging - -Once you're done troubleshooting, you should disable query logging to prevent it from unnecessarily consuming resources. - -- **Long-running transactions**: - - ~~~ sql - > SET CLUSTER SETTING sql.trace.txn.enable_threshold = '0s'; - ~~~ - -- **All queries**: - - ~~~ sql - > SET CLUSTER SETTING sql.trace.log_statement_execute = false; - ~~~ - ## See Also - [Troubleshooting Overview](troubleshooting-overview.html) diff --git a/v1.1/manage-long-running-queries.md b/v1.1/manage-long-running-queries.md new file mode 100644 index 00000000000..0880575af23 --- /dev/null +++ b/v1.1/manage-long-running-queries.md @@ -0,0 +1,69 @@ +--- +title: Manage Long-Running Queries +summary: Learn how to identify and cancel long-running queries. +toc: false +--- + +This page shows you how to identify and, if necessary, cancel SQL queries that are taking longer than expected to process. + +{{site.data.alerts.callout_info}}Schema changes (statements beginning with ALTER) cannot currently be cancelled. However, to monitor the progress of schema changes, you can use SHOW JOBS.{{site.data.alerts.end}} + +
+ +## Identify Long-Running Queries + +Use the [`SHOW QUERIES`](show-queries.html) statement to list details about currently active SQL queries, including each query's `start` timestamp: + +~~~ sql +> SHOW QUERIES; +~~~ + +~~~ ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| query_id | node_id | username | start | query | client_address | application_name | distributed | phase | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +| 14db657443230c3e0000000000000001 | 1 | root | 2017-08-16 18:00:50.675151+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54119 | test_app | false | executing | +| 14db657443b68c7d0000000000000001 | 1 | root | 2017-08-16 18:00:50.684818+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54123 | test_app | false | executing | +| 14db65744382c2340000000000000001 | 1 | root | 2017-08-16 18:00:50.681431+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.56:54103 | test_app | false | executing | +| 14db657443c9dc660000000000000001 | 1 | root | 2017-08-16 18:00:50.686083+00:00 | SHOW CLUSTER QUERIES | 192.168.12.56:54108 | | NULL | preparing | +| 14db657443e30a850000000000000003 | 3 | root | 2017-08-16 18:00:50.68774+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.58:54118 | test_app | false | executing | +| 14db6574439f477d0000000000000003 | 3 | root | 2017-08-16 18:00:50.6833+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.58:54122 | test_app | false | executing | +| 14db6574435817d20000000000000002 | 2 | root | 2017-08-16 18:00:50.678629+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54121 | test_app | false | executing | +| 14db6574433c621f0000000000000002 | 2 | root | 2017-08-16 18:00:50.676813+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54124 | test_app | false | executing | +| 14db6574436f71d50000000000000002 | 2 | root | 2017-08-16 18:00:50.680165+00:00 | UPSERT INTO test.kv(k, v) VALUES ($1, $2) | 192.168.12.57:54117 | test_app | false | executing | ++----------------------------------+---------+----------+----------------------------------+-------------------------------------------+---------------------+------------------+-------------+-----------+ +(9 rows) +~~~ + +You can also filter for queries that have been running for a certain amount of time. For example, to find queries that have been running for more than 3 hours, you would run the following: + +~~~ sql +> SELECT * FROM [SHOW CLUSTER QUERIES] + WHERE start < (now() - INTERVAL '3 hours'); +~~~ + +## Cancel Long-Running Queries + +Once you've identified a long-running query via [`SHOW QUERIES`](show-queries.html), note the `query_id` and use it with the [`CANCEL QUERY`](cancel-query.html) statement: + +~~~ sql +> CANCEL QUERY '14dacc1f9a781e3d0000000000000001'; +~~~ + +When a query is successfully cancelled, CockoachDB sends a `query execution canceled` error to the client that issued the query. + +- If the canceled query was a single, standalone statement, no further action is required by the client. +- If the canceled query was part of a larger, multi-statement [transaction](transactions.html), the client should then issue a [`ROLLBACK`](rollback-transaction.html) statement. + +## Improve Query Performance + +After cancelling a long-running query, use the [`EXPLAIN`](explain.html) statement to examine it. It's possible that the query was slow because it performs a full-table scan. In these cases, you can likely improve the query's performance by [adding an index](create-index.html). + +*(More guidance around query performance optimization forthcoming.)* + +## See Also + +- [`SHOW QUERIES`](show-queries.html) +- [`CANCEL QUERY`](cancel-query.html) +- [`EXPLAIN`](explain.html) +- [Query Behavior Troubleshooting](query-behavior-troubleshooting.html) diff --git a/v1.1/query-behavior-troubleshooting.md b/v1.1/query-behavior-troubleshooting.md index 35f6ed8795d..5685e05fad9 100644 --- a/v1.1/query-behavior-troubleshooting.md +++ b/v1.1/query-behavior-troubleshooting.md @@ -1,6 +1,6 @@ --- title: Query Behavior Troubleshooting -summary: Learn how to troubleshoot issues with specific queries with CockroachDB +summary: Learn how to troubleshoot issues with specific queries with CockroachDB toc: false --- @@ -14,15 +14,15 @@ If your queries return unexpected results, there are several possibilities: - You’ve encountered a [known limitation](https://github.com/cockroachdb/cockroach/issues?q=is%3Aopen+is%3Aissue+label%3Aknown-limitation), [UX surprise](https://github.com/cockroachdb/cockroach/issues?utf8=%E2%9C%93&q=is%3Aopen%20is%3Aissue%20label%3Aux-surprise) or other problem with [SQL semantics](https://github.com/cockroachdb/cockroach/issues?utf8=%E2%9C%93&q=is%3Aopen%20is%3Aissue%20label%3Asql-semantics). Feel free to leave a comment on the existing issue indicating that you’ve encountered a problem as well. - Your application has a bug. It's always worthwhile to check and double-check your application’s logic before filing an issue. That said, you can always [reach out for support](support-resources.html). - - CockroachDB has a bug. Please [file an issue](file-an-issue.html). +- CockroachDB has a bug. Please [file an issue](file-an-issue.html). ## Performance Issues -If your queries take much longer than expected, there are a few things you can check into: +If queries are taking longer than expected to process, there are a few things you can check into: - Review your deployment's monitoring. General network latency or partitioning events can affect query response times. -- [Log and debug long-running queries/transactions](debug-and-error-logs.html#log-queries). +- [Identify and cancel long-running queries](manage-long-running-queries.html). If you're still unable to determine why the query executes slowly, please [file an issue](file-an-issue.html).