Managed Service for PostgreSQL API, gRPC: PerformanceDiagnosticsService
Статья создана
Обновлена 6 сентября 2023 г.
A set of methods for PostgreSQL performance diagnostics.
Call | Description |
---|---|
ListRawSessionStates | Retrieves raw statistics on sessions. |
ListRawStatements | Retrieves statistics on planning and execution of SQL statements (queries). |
Calls PerformanceDiagnosticsService
ListRawSessionStates
Retrieves raw statistics on sessions. Corresponds to the pg_stat_activity view
rpc ListRawSessionStates (ListRawSessionStatesRequest) returns (ListRawSessionStatesResponse)
ListRawSessionStatesRequest
Field | Description |
---|---|
cluster_id | string Required. ID of a PostgreSQL cluster to request session statistics for. To get a PostgreSQL cluster ID, use the ClusterService.List request. The maximum string length in characters is 50. |
from_time | google.protobuf.Timestamp Beginning of the period for which you need to request data (in the RFC3339 |
to_time | google.protobuf.Timestamp End of the period for which you need to request data (in the RFC3339 |
page_size | int64 The maximum number of results per page to return. If the number of the results is larger than page_size , the service returns ListRawSessionStatesResponse.next_page_token. You can use it to get the next page of the results in subsequent requests. The maximum value is 10000. |
page_token | string Page token. To get the next page of results, set page_token to the ListRawSessionStatesResponse.next_page_token returned by the previous PostgreSQL session list request. The maximum string length in characters is 100. |
ListRawSessionStatesResponse
Field | Description |
---|---|
session_states[] | SessionState List of PostgreSQL sessions. |
next_page_token | string This token allows you to get the next page of results when requesting the PostgreSQL session list. If the number of the results is larger than ListRawSessionStatesRequest.page_size, use the next_page_token as the value for the ListRawSessionStatesRequest.page_token parameter in the next request. Each subsequent request will have its own next_page_token to continue paging through the results. |
SessionState
Field | Description |
---|---|
time | google.protobuf.Timestamp Time of collecting statistics on sessions (in the RFC3339 |
host | string Host of the connected client. |
pid | int64 Server process ID. For client connections, this is a client connection ID. |
database | string Database ID. |
user | string User ID. |
application_name | string Application name on the connected client. |
backend_start | google.protobuf.Timestamp Time when a given process was started. For client connections, this is the time when the client connected to the server. |
xact_start | google.protobuf.Timestamp Time when a transaction of a given process was started. Returns [NULL] if no transaction is active. If the currently active query is the first of its transaction, the value of this parameter is equal to the value of the query_start parameter. |
query_start | google.protobuf.Timestamp Time when the currently active query was started. If the state parameter does not take the value [active], the parameter returns the time when the lastest query was started. |
state_change | google.protobuf.Timestamp Time when the state parameter was last changed. |
wait_event_type | string Type of event for which the backend is waiting. Such an event is called a wait event. A backend refers to the process that maintains the client connection. For the list of wait events, see the PostgreSQL documentation |
wait_event | string Wait event name. For the list of such names, see the PostgreSQL documentation |
state | string Current backend state. For the list of possible values, see the PostgreSQL documentation |
query | string Text of the most recent query. If the state parameter takes the value [active], the parameter shows the currently executing query. For the rest of the states, the parameter shows the last query that was executed. By default, the query text is truncated to 1024 bytes. |
backend_type | string Current backend type. For the list of possible values, see the PostgreSQL documentation |
client_addr | string IP address of the connected client. The parameter returns [NULL] in the following cases:
|
client_hostname | string Host name of the connected client (relevant for IP connections). |
client_port | int64 TCP port number that the client is using for communication with the server. Returns [-1] if the client is connected via a Unix socket on the server. Returns [NULL] if a given process is internal (for example, autovacuum). |
backend_xid | int64 Top-level transaction ID, if any. |
backend_xmin | int64 Current [xmin horizon]. |
blocking_pids | string Process IDs that are blocking a given server process ID. |
query_id | string Query ID. |
ListRawStatements
Retrieves statistics on planning and execution of SQL statements (queries).
rpc ListRawStatements (ListRawStatementsRequest) returns (ListRawStatementsResponse)
ListRawStatementsRequest
Field | Description |
---|---|
cluster_id | string Required. ID of a PostgreSQL cluster to request query statistics for. To get a PostgreSQL cluster ID, use the ClusterService.List method. The maximum string length in characters is 50. |
from_time | google.protobuf.Timestamp Beginning of the period for which you need to request data (in the RFC3339 |
to_time | google.protobuf.Timestamp End of the period for which you need to request data (in the RFC3339 |
page_size | int64 The maximum number of results per page to return. If the number of the results is larger than page_size , the service returns ListRawStatementsResponse.next_page_token. You can use it to get the next page of the results in subsequent requests. The maximum value is 10000. |
page_token | string Page token. To get the next page of results, set page_token to the ListRawStatementsResponse.next_page_token returned by the previous SQL statement list request. The maximum string length in characters is 100. |
ListRawStatementsResponse
Field | Description |
---|---|
statements[] | QueryStatement List of SQL statements (queries). |
next_page_token | string This token allows you to get the next page of results when requesting the PostgreSQL session list. If the number of the results is larger than ListRawStatementsRequest.page_size, use the next_page_token as the value for the ListRawStatementsRequest.page_token parameter in the next request. Each subsequent request will have its own next_page_token to continue paging through the results. |
QueryStatement
Field | Description |
---|---|
key | PrimaryKey Primary keys in tables with the statistics on planning and execution of queries. |
stats | QueryStats Statistics on planning and execution of queries. |
PrimaryKey
Field | Description |
---|---|
host | string Host of the connected client. |
user | string User ID. |
database | string Database ID. |
toplevel | bool Returns [true] if a query is executed as a top-level SQL statement or if the pg_stat_statements.track |
query_id | string Query ID. |
plan_id | string Query planning ID. |
QueryStats
Field | Description |
---|---|
time | google.protobuf.Timestamp Time of collecting statistics on planning and execution of queries. |
query | string Statement text. |
normalized_plan | string Normalized query plan. |
example_plan | string Example of a query execution plan (without normalization). |
plans | int64 Number of times that a query was planned. The parameter returns a non-zero value if the pg_stat_statements.track_planning |
total_plan_time | double Total time taken to plan a query, in milliseconds. The parameter returns a non-zero value if the [pg_stat_statements.track_planning] parameter is enabled. |
min_plan_time | double Minimum time taken to plan a query, in milliseconds. The parameter returns a non-zero value if the [pg_stat_statements.track_planning] parameter is enabled. |
max_plan_time | double Maximum time taken to plan a query, in milliseconds. The parameter returns a non-zero value if the [pg_stat_statements.track_planning] parameter is enabled. |
mean_plan_time | double Average time taken to plan a query, in milliseconds. The parameter returns a non-zero value if the [pg_stat_statements.track_planning] parameter is enabled. |
stddev_plan_time | double Population standard deviation of the time taken to plan a query, in milliseconds. The parameter returns a non-zero value if the [pg_stat_statements.track_planning] parameter is enabled. |
calls | int64 Number of times that a query was executed. |
total_time | double Total time taken to execute a query, in milliseconds. |
min_time | double Minimum time taken to execute a query, in milliseconds. |
max_time | double Maximum time taken to execute a query, in milliseconds. |
mean_time | double Average time taken to execute a query, in milliseconds. |
stddev_time | double Population standard deviation of the time taken to execute a query, in milliseconds. |
rows | int64 Number of retrieved or affected rows. |
shared_blks_hit | int64 Number of shared blocks that are hit from cache. |
shared_blks_read | int64 Number of read shared blocks. |
shared_blks_dirtied | int64 Number of 'dirtied' shared blocks. |
shared_blks_written | int64 Number of written shared blocks. |
local_blks_hit | int64 Number of local blocks that are hit from cache. |
local_blks_read | int64 Number of read local blocks. |
local_blks_dirtied | int64 Number of 'dirtied' local blocks. |
local_blks_written | int64 Number of written local blocks. |
temp_blks_read | int64 Number of read temporary blocks. |
temp_blks_written | int64 Number of written temporary blocks. |
blk_read_time | double Time taken to read data blocks, in milliseconds. The parameter returns a non-zero value if the track_io_timing |
blk_write_time | double Time taken to record data blocks, in milliseconds. The parameter returns a non-zero value if the [track_io_timing] parameter is enabled. |
temp_blk_read_time | double Time taken to read temporary data blocks, in milliseconds. The parameter returns a non-zero value if the [track_io_timing] parameter is enabled. |
temp_blk_write_time | double Time taken to record temporary data blocks, in milliseconds. The parameter returns a non-zero value if the [track_io_timing] parameter is enabled. |
wal_records | int64 Number of WAL records generated during a given period. |
wal_fpi | int64 Number of WAL full page images generated during a given period. |
wal_bytes | int64 Number of WAL logs generated during a given period, in bytes. |
jit_functions | int64 Number of JIT-compiled functions. |
jit_generation_time | double Time taken to generate JIT code, in milliseconds. |
jit_inlining_count | int64 Number of times that functions have been inlined. |
jit_inlining_time | double Time taken to inline functions, in milliseconds. |
jit_optimization_count | int64 Number of times that a query was optimized. |
jit_optimization_time | double Time taken to optimize a query, in milliseconds. |
jit_emission_count | int64 Number of times that code was emitted. |
jit_emission_time | double Time taken to emit code. |
startup_cost | int64 Cost of receiving a response to a query before the first row of the response is issued. |
total_cost | int64 Cost of receiving a response to a query when all the rows of the response are issued. |
plan_rows | int64 Expected number of rows that a given plan node should issue. |
plan_width | int64 Expected average size of rows that a given plan node should issue. |
reads | int64 Number of bytes that the filesystem layer has read. |
writes | int64 Number of bytes that the filesystem layer has written. |
user_time | double User CPU time used. |
system_time | double System CPU time used. |