mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 22:20:56 +00:00
refactor(database/rawTransaction): per-query profiling
This commit is contained in:
1 parent
c87885eb8a
commit
e57a983bc0
1 file changed
+5
-4
@@ -34,12 +34,13 @@ export const rawTransaction = async (
|
|||||||
await connection.commit();
|
await connection.commit();
|
||||||
|
|
||||||
const [profiler] = <RowDataPacket[]>(
|
const [profiler] = <RowDataPacket[]>(
|
||||||
await connection.query('SELECT SUM(DURATION) AS `duration` FROM INFORMATION_SCHEMA.PROFILING')
|
await connection.query('SELECT SUM(DURATION) AS `duration` FROM INFORMATION_SCHEMA.PROFILING GROUP BY QUERY_ID')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (profiler[0]?.duration) {
|
if (profiler.length > 0) {
|
||||||
for (const transaction of transactions) {
|
for (let i = 0; i < transactions.length; i++) {
|
||||||
logQuery(invokingResource, transaction.query, parseFloat(profiler[0].duration) / transactions.length, transaction.params);
|
const transaction = transactions[i]
|
||||||
|
logQuery(invokingResource, transaction.query, parseFloat(profiler[i].duration), transaction.params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user