Skip to main content

ListRawStatements

Retrieves statistics on planning and execution of SQL statements (queries).

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const ListRawStatementsRequest =
cloudApi.mdb.postgresql_perf_diag_service.ListRawStatementsRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(
serviceClients.PerformanceDiagnosticsServiceClient
);

const result = await client.listRawStatements(
ListRawStatementsRequest.fromPartial({
clusterId: "clusterId",
// fromTime: {
// seconds: 0,
// nanos: 0
// },
// toTime: {
// seconds: 0,
// nanos: 0
// },
// pageSize: 0,
// pageToken: "pageToken"
})
);
console.log(result);
})();

ListRawStatementsRequest

clusterId : string

ID of a PostgreSQL cluster to request query statistics for.

To get a PostgreSQL cluster ID, use the ClusterService.List method.

fromTime : google.protobuf.Timestamp

Beginning of the period for which you need to request data (in the RFC3339 text format).

toTime : google.protobuf.Timestamp

End of the period for which you need to request data (in the RFC3339 text format).

pageSize : 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.

pageToken : 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.

ListRawStatementsResponse

statements : QueryStatement

List of SQL statements (queries).

nextPageToken : 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

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

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 parameter is set to the value top.

queryId : string

Query ID.

planId : string

Query planning ID.

QueryStats

time : google.protobuf.Timestamp

Time of collecting statistics on planning and execution of queries.

query : string

Statement text.

normalizedPlan : string

Normalized query plan.

examplePlan : 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 parameter is enabled.

totalPlanTime : 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.

minPlanTime : 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.

maxPlanTime : 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.

meanPlanTime : 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.

stddevPlanTime : 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.

totalTime : double

Total time taken to execute a query, in milliseconds.

minTime : double

Minimum time taken to execute a query, in milliseconds.

maxTime : double

Maximum time taken to execute a query, in milliseconds.

meanTime : double

Average time taken to execute a query, in milliseconds.

stddevTime : double

Population standard deviation of the time taken to execute a query, in milliseconds.

rows : int64

Number of retrieved or affected rows.

sharedBlksHit : int64

Number of shared blocks that are hit from cache.

sharedBlksRead : int64

Number of read shared blocks.

sharedBlksDirtied : int64

Number of 'dirtied' shared blocks.

sharedBlksWritten : int64

Number of written shared blocks.

localBlksHit : int64

Number of local blocks that are hit from cache.

localBlksRead : int64

Number of read local blocks.

localBlksDirtied : int64

Number of 'dirtied' local blocks.

localBlksWritten : int64

Number of written local blocks.

tempBlksRead : int64

Number of read temporary blocks.

tempBlksWritten : int64

Number of written temporary blocks.

blkReadTime : double

Time taken to read data blocks, in milliseconds.

The parameter returns a non-zero value if the track_io_timing parameter is enabled.

blkWriteTime : double

Time taken to record data blocks, in milliseconds.

The parameter returns a non-zero value if the track_io_timing parameter is enabled.

tempBlkReadTime : 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.

tempBlkWriteTime : 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.

walRecords : int64

Number of WAL records generated during a given period.

walFpi : int64

Number of WAL full page images generated during a given period.

walBytes : int64

Number of WAL logs generated during a given period, in bytes.

jitFunctions : int64

Number of JIT-compiled functions.

jitGenerationTime : double

Time taken to generate JIT code, in milliseconds.

jitInliningCount : int64

Number of times that functions have been inlined.

jitInliningTime : double

Time taken to inline functions, in milliseconds.

jitOptimizationCount : int64

Number of times that a query was optimized.

jitOptimizationTime : double

Time taken to optimize a query, in milliseconds.

jitEmissionCount : int64

Number of times that code was emitted.

jitEmissionTime : double

Time taken to emit code.

startupCost : int64

Cost of receiving a response to a query before the first row of the response is issued.

totalCost : int64

Cost of receiving a response to a query when all the rows of the response are issued.

planRows : int64

Expected number of rows that a given plan node should issue.

planWidth : 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.

userTime : double

User CPU time used.

systemTime : double

System CPU time used.