postgresql_current_queries
Creates, updates, deletes, gets or lists a postgresql_current_queries resource.
Overview​
| Name | postgresql_current_queries |
| Type | Resource |
| Id | ovh.public_cloud_database.postgresql_current_queries |
Fields​
The following fields are returned by SELECT queries:
- get
- list
successful operation
| Name | Datatype | Description |
|---|---|---|
application_name | string | Name of the application that initiated the query (wire: applicationName) |
database_name | string | Name of the database the query is running on (wire: databaseName) |
user_name | string | Name of the user running the query (wire: userName) |
backend_started_at | string (date-time) | Timestamp when the backend process started (wire: backendStartedAt) |
client_ip | string (ipv4) | IP address of the client (example: 192.0.2.0) (wire: clientIp) |
client_port | integer | Port of the client connection (wire: clientPort) |
pid | integer | Process ID of the connection |
query | string | SQL text of the currently running query |
query_duration | number | Duration of the query in seconds (wire: queryDuration) |
query_started_at | string (date-time) | Timestamp when the query started (wire: queryStartedAt) |
state | string | Current state of the connection (ACTIVE, DISABLED, FASTPATH_FUNCTION_CALL, IDLE, IDLE_IN_TRANSACTION, IDLE_IN_TRANSACTION_ABORTED) |
wait_event | string | Name of the wait event the connection is waiting on, if any (wire: waitEvent) |
wait_event_type | string | Type of wait event the connection is waiting on, if any (ACTIVITY, BUFFER_PIN, CLIENT, EXTENSION, IO, IPC, LOCK, LWLOCK, TIMEOUT) (wire: waitEventType) |
A currently running query on a managed database service
| Name | Datatype | Description |
|---|---|---|
application_name | string | Name of the application that initiated the query (wire: applicationName) |
database_name | string | Name of the database the query is running on (wire: databaseName) |
user_name | string | Name of the user running the query (wire: userName) |
backend_started_at | string (date-time) | Timestamp when the backend process started (wire: backendStartedAt) |
client_ip | string (ipv4) | IP address of the client (example: 192.0.2.0) (wire: clientIp) |
client_port | integer | Port of the client connection (wire: clientPort) |
pid | integer | Process ID of the connection |
query | string | SQL text of the currently running query |
query_duration | number | Duration of the query in seconds (wire: queryDuration) |
query_started_at | string (date-time) | Timestamp when the query started (wire: queryStartedAt) |
state | string | Current state of the connection (ACTIVE, DISABLED, FASTPATH_FUNCTION_CALL, IDLE, IDLE_IN_TRANSACTION, IDLE_IN_TRANSACTION_ABORTED) |
wait_event | string | Name of the wait event the connection is waiting on, if any (wire: waitEvent) |
wait_event_type | string | Type 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:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | query_pid, service_id, project_id | limit, offset | Returns the SQL text, state and duration of a running query, identified by its process ID. (Beta version) |
list | select | service_id, project_id | x_pagination_cursor, x_pagination_size | Returns the queries running on the service, with their client, user, state and duration. (Beta version) |
cancel | exec | queryPid, serviceId, project_id | Cancels 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.
| Name | Datatype | Description |
|---|---|---|
api_host | string | The 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_id | string | The Public Cloud project ID. Resolved from OVH_CLOUD_PROJECT_SERVICE when set. |
queryPid | integer | Query pid |
query_pid | integer | Query pid (wire: queryPid) |
serviceId | string (uuid) | Service ID |
service_id | string (uuid) | Service ID (wire: serviceId) |
limit | integer | Maximum number of queries to return |
offset | integer | Number of queries to skip before returning results |
x_pagination_cursor | string | Pagination cursor (wire: X-Pagination-Cursor) |
x_pagination_size | integer | Pagination size (wire: X-Pagination-Size) |
SELECT examples​
- get
- list
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.postgresql_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 }}'
;
Returns the queries running on the service, with their client, user, state and duration. (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.postgresql_current_queries
WHERE service_id = '{{ service_id }}' -- required
AND project_id = '{{ project_id }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
AND x_pagination_cursor = '{{ x_pagination_cursor }}'
AND x_pagination_size = '{{ x_pagination_size }}'
;
Lifecycle Methods​
EXEC variables use wire (API) names.
- cancel
Cancels a running query gracefully. Set terminate to true to force its termination instead. (Beta version)
EXEC ovh.public_cloud_database.postgresql_current_queries.cancel
@queryPid='{{ queryPid }}' --required,
@serviceId='{{ serviceId }}' --required,
@project_id='{{ project_id }}' --required unless OVH_CLOUD_PROJECT_SERVICE is set
@@json=
'{
"terminate": {{ terminate }}
}'
;