Skip to content

Commit 53f586c

Browse files
committed
chore: reduce and reset
1 parent f44b10c commit 53f586c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/hasura/hasura.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ export class HasuraService {
164164
}
165165
}
166166
}
167+
168+
if(completed > 0) {
169+
await this.postgresService.query(`select pg_stat_reset();`);
170+
await this.postgresService.query(`select pg_stat_statements_reset();`);
171+
}
172+
167173
this.logger.log(`Migrations: ${completed} Completed`);
168174
}
169175

src/postgres/postgres.controller.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export class PostgresController {
5757
SUM(local_blks_hit) AS local_blks_hit,
5858
SUM(local_blks_read) AS local_blks_read
5959
FROM pg_stat_statements
60-
WHERE query NOT LIKE '/* pgbouncer */%'
6160
GROUP BY queryid, query
6261
HAVING SUM(calls) > 5
6362
ORDER BY mean_exec_time DESC
@@ -125,10 +124,9 @@ export class PostgresController {
125124
local_blks_hit,
126125
local_blks_read
127126
FROM pg_stat_statements
128-
WHERE query NOT LIKE '/* pgbouncer */%'
129-
AND calls > 5
127+
WHERE calls > 5
130128
ORDER BY mean_exec_time DESC
131-
LIMIT 100
129+
LIMIT 50
132130
`);
133131

134132
return (result as unknown as any[]).map((row) => ({
@@ -321,7 +319,6 @@ export class PostgresController {
321319
EXTRACT(EPOCH FROM (now() - query_start)) as duration_seconds
322320
FROM pg_stat_activity
323321
WHERE state != 'idle'
324-
AND query NOT LIKE '/* pgbouncer */%'
325322
AND pid != pg_backend_pid()
326323
ORDER BY query_start ASC
327324
`);

0 commit comments

Comments
 (0)