Skip to content

Commit bae40fa

Browse files
gayratvgtsufiev
authored andcommitted
feat(executeQuery): add collectStats parameter
Now you can receive statistics information, for example, the number of reading rows, affectedShards and so on. const data = await session.executeQuery( 'select * from series', {}, AUTO_TX, undefined, undefined, Ydb.Table.QueryStatsCollection.Mode.STATS_COLLECTION_BASIC ); const stats_rows_read = (data.queryStats!.queryPhases!['0']. tableAccess!['0'].reads!.rows as Long).low; const affectedShards = (data.queryStats!.queryPhases!['0']. affectedShards as Long).low;
1 parent b80de4e commit bae40fa

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export {
3232
ReplicationPolicy,
3333
CompactionPolicy,
3434
ExecutionPolicy,
35-
CachingPolicy
35+
CachingPolicy,
36+
AUTO_TX
3637
} from './table';
3738
export {getCredentialsFromEnv, getSACredentialsFromJson} from './parse-env-vars';
3839
export {parseConnectionString, ParsedConnectionString} from './parse-connection-string';

src/table.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ interface INewTransaction {
8686
commitTx: boolean
8787
}
8888

89-
const AUTO_TX: INewTransaction = {
89+
export const AUTO_TX: INewTransaction = {
9090
beginTx: {
9191
serializableReadWrite: {}
9292
},
@@ -329,6 +329,7 @@ export class Session extends EventEmitter implements ICreateSessionResult {
329329
txControl: IExistingTransaction | INewTransaction = AUTO_TX,
330330
operationParams?: IOperationParams,
331331
settings?: ExecDataQuerySettings,
332+
collectStats?: Ydb.Table.QueryStatsCollection.Mode | null
332333
): Promise<ExecuteQueryResult> {
333334
this.logger.trace('preparedQuery %o', query);
334335
this.logger.trace('parameters %o', params);
@@ -352,6 +353,7 @@ export class Session extends EventEmitter implements ICreateSessionResult {
352353
parameters: params,
353354
query: queryToExecute,
354355
operationParams,
356+
collectStats
355357
};
356358
if (keepInCache) {
357359
request.queryCachePolicy = {keepInCache};

0 commit comments

Comments
 (0)