Skip to main content

mysql_current_queries

Creates, updates, deletes, gets or lists a mysql_current_queries resource.

Overview​

Namemysql_current_queries
TypeResource
Idovh.public_cloud_database.mysql_current_queries

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
application_namestringName of the application that initiated the query (wire: applicationName)
database_namestringName of the database the query is running on (wire: databaseName)
user_namestringName of the user running the query (wire: userName)
backend_started_atstring (date-time)Timestamp when the backend process started (wire: backendStartedAt)
client_ipstring (ipv4)IP address of the client (example: 192.0.2.0) (wire: clientIp)
client_portintegerPort of the client connection (wire: clientPort)
pidintegerProcess ID of the connection
querystringSQL text of the currently running query
query_durationnumberDuration of the query in seconds (wire: queryDuration)
query_started_atstring (date-time)Timestamp when the query started (wire: queryStartedAt)
statestringCurrent state of the connection (ACTIVE, DISABLED, FASTPATH_FUNCTION_CALL, IDLE, IDLE_IN_TRANSACTION, IDLE_IN_TRANSACTION_ABORTED)
wait_eventstringName of the wait event the connection is waiting on, if any (wire: waitEvent)
wait_event_typestringType of wait event the connection is waiting on, if any (ACTIVITY, BUFFER_PIN, CLIENT, EXTENSION, IO, IPC, LOCK, LWLOCK, TIMEOUT) (wire: waitEventType)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectquery_pid, service_id, project_idlimit, offsetReturns the SQL text, state and duration of a running query, identified by its process ID. (Beta version)
listselectservice_id, project_idx_pagination_cursor, x_pagination_sizeReturns the queries running on the service, with their client, user, state and duration. (Beta version)
cancelexecqueryPid, serviceId, project_idCancels a running query gracefully. Set terminate to true to force its termination instead. (Beta version)

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
project_idstringThe Public Cloud project ID. Resolved from OVH_CLOUD_PROJECT_SERVICE when set.
queryPidintegerQuery pid
query_pidintegerQuery pid (wire: queryPid)
serviceIdstring (uuid)Service ID
service_idstring (uuid)Service ID (wire: serviceId)
limitintegerMaximum number of queries to return
offsetintegerNumber of queries to skip before returning results
x_pagination_cursorstringPagination cursor (wire: X-Pagination-Cursor)
x_pagination_sizeintegerPagination size (wire: X-Pagination-Size)

SELECT examples​

Returns the SQL text, state and duration of a running query, identified by its process ID. (Beta version)

SELECT
application_name,
database_name,
user_name,
backend_started_at,
client_ip,
client_port,
pid,
query,
query_duration,
query_started_at,
state,
wait_event,
wait_event_type
FROM ovh.public_cloud_database.mysql_current_queries
WHERE query_pid = '{{ query_pid }}' -- required
AND service_id = '{{ service_id }}' -- required
AND project_id = '{{ project_id }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
AND limit = '{{ limit }}'
AND offset = '{{ offset }}'
;

Lifecycle Methods​

EXEC variables use wire (API) names.

Cancels a running query gracefully. Set terminate to true to force its termination instead. (Beta version)

EXEC ovh.public_cloud_database.mysql_current_queries.cancel
@queryPid='{{ queryPid }}' --required,
@serviceId='{{ serviceId }}' --required,
@project_id='{{ project_id }}' --required unless OVH_CLOUD_PROJECT_SERVICE is set
@@json=
'{
"terminate": {{ terminate }}
}'
;