SHOW_SERVER_STATUS

SHOW_SERVER_STATUS returns a list of active sessions across the cluster.

To list active statements on the current worker only, see SHOW_CONNECTIONS.

Syntax

The following is the correct syntax when showing your server status:

SELECT SHOW_SERVER_STATUS()

Parameters

The Parameters section is not relevant for the SHOW_SERVER_STATUS statement.

Returns

The SHOW_SERVER_STATUS function returns a list of active sessions. If no sessions are active across the cluster, the result set will be empty.

The following table shows the SHOW_SERVER_STATUS result columns;

Result Columns

service

Statement Service Name

instance id

Shows the worker ID.

connection_id

Shows the client’s connection ID, the same ID the worker records in its log.

server ip

Shows the worker end-point IP.

server port

Shows the worker end-point port.

database_name

Shows the statement’s database name.

user_name

Shows the username running the statement.

client ip

Shows the client IP.

statement id

Shows the statement ID.

statement

Shows the statement text.

statement start time

Shows the statement start timestamp.

statement status

Shows the statement status (see table below).

statement status start

Shows the most recently updated timestamp.

The following table shows the statement status values:

Statement Status Values

Status

Description

Preparing

The statement is being prepared.

In queue

The statement is waiting for execution.

Initializing

The statement has entered execution checks.

Executing

The statement is executing.

Stopping

The statement is in the process of stopping.

Notes

This utility shows the active sessions. Some sessions may be actively connected, but not running any statements.

Example

Using SHOW_SERVER_STATUS to Get Statement IDs

The following example shows how to use the SHOW_SERVER_STATUS statement to get statement IDs:

SELECT SHOW_SERVER_STATUS();
service | instance id | connection_id | server ip     | server port | database_name | user_name        | client ip     | statement id | statement                                                                                             | statement start time | statement status | statement status start
--------+------------+---------------+---------------+------------+---------------+------------------+---------------+-------------+-------------------------------------------------------------------------------------------------------+---------------------+-----------------+---------------------
sqream  | sqream_2   |  19           | 192.168.0.111 |       5000 | master        | etl              | 192.168.0.011 |2484923      | SELECT t1.account, t1.msisd from table a t1 join table b t2 on t1.id = t2.id where t1.msid='123123';  | 2022-01-17 16:19:31 | Executing       | 2022-01-17 16:19:32
sqream  | sqream_1   |  2            | 192.168.1.112 |       5000 | master        | etl              | 192.168.1.112 |2484924      | select show_server_status();                                                                          | 2022-01-17 16:19:39 | Executing       | 2022-01-17 16:19:39
sqream  | None       |  248          | 192.168.1.112 |       5007 | master        | maintenance_user | 192.168.1.112 |2484665      | select * from  sqream_catalog.tables;                                                                 | 2022-01-17 15:55:01 | In Queue        | 2022-01-17 15:55:02

The statement ID is 128, running on worker 192.168.1.91.

Permissions

Using the SHOW_SERVER_STATUS command requires no special permissions.