Manage queries

This section describes facilities for query management.

1. List all running queries

The procedure for listing queries, dbms.listQueries(), is replaced by the command for listing transactions, SHOW TRANSACTIONS. This command returns information about the currently executing query in the transaction. For more information on the command, see the Cypher manual → SHOW TRANSACTIONS command.

2. List all active locks for a query

An administrator is able to view all active locks held by the transaction executing the query with the queryId.

Syntax:

CALL dbms.listActiveLocks(queryId)

Returns:

Name Type Description

mode

String

Lock mode corresponding to the transaction.

resourceType

String

Resource type of the locked resource

resourceId

Integer

Resource id of the locked resource .

Example 1. Viewing active locks for a query

The following example shows the active locks held by transaction executing query with id query-614

CALL dbms.listActiveLocks( "query-614" )
╒════════╤══════════════╤════════════╕
│"mode"  │"resourceType"│"resourceId"│
╞════════╪══════════════╪════════════╡
│"SHARED"│"SCHEMA"      │0           │
└────────┴──────────────┴────────────┘
1 row

The following example shows the active locks for all currently executing queries by yielding the queryId from dbms.listQueries procedure

CALL dbms.listQueries() YIELD queryId, query, database
CALL dbms.listActiveLocks( queryId ) YIELD resourceType, resourceId, mode
RETURN queryId, query, resourceType, resourceId, mode, database
╒════════════╤══════════════════════════════╤══════════════╤════════════╤════════╤════════════╕
│"queryId"   │"query"                       │"resourceType"│"resourceId"│"mode"  │"database"  │
╞════════════╪══════════════════════════════╪══════════════╪════════════╪════════╪════════════╡
│"query-614" │"match (n), (m), (o), (p), (q)│"SCHEMA"      │0           │"SHARED"│"myDb"      │
│            │ return count(*)"             │              │            │        │            │
├────────────┼──────────────────────────────┼──────────────┼────────────┼────────┼────────────┤
│"query-684" │"CALL dbms.listQueries() YIELD│"SCHEMA"      │0           │"SHARED"│"myOtherDb" │
│            │ .."                          │              │            │        │            │
└────────────┴──────────────────────────────┴──────────────┴────────────┴────────┴────────────┘
2 rows

3. Terminate queries

The procedures for terminating queries, dbms.killQueries(queryIds) and dbms.killQuery(queryId), are replaced by the command for terminating transactions, TERMINATE TRANSACTIONS transactionIds. These commands use the transactionId instead of the queryId, which can be found using the SHOW TRANSACTIONS command.

The TERMINATE TRANSACTION privilege determines what transactions can be terminated. However, the current user can always terminate all of their own transactions.

Syntax:

TERMINATE TRANSACTIONS transactionIds

Argument:

Name Type Description

transactionIds

Comma-separated strings

The IDs of all the transactions to be terminated.

transactionIds

Single string parameter

The ID of the transaction to be terminated.

transactionIds

List parameter

The IDs of all the transactions to be terminated.

For more information on the command, see the Cypher manual → TERMINATE TRANSACTIONS command.