Skip to content

Commit 51c84a3

Browse files
committed
refactor(database/rawExecute): split batched query logs
1 parent e57a983 commit 51c84a3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/database/rawExecute.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ export const rawExecute = (
5959
}
6060

6161
if (index === parametersLength - 1) {
62-
const [profiler] = <RowDataPacket[]> await connection.query('SELECT SUM(DURATION) AS `duration` FROM INFORMATION_SCHEMA.PROFILING');
63-
64-
if (profiler[0]?.duration) logQuery(invokingResource, query, parseFloat(profiler[0].duration), parameters);
62+
const [profiler] = <RowDataPacket[]>(
63+
await connection.query('SELECT SUM(DURATION) AS `duration` FROM INFORMATION_SCHEMA.PROFILING GROUP BY QUERY_ID')
64+
);
65+
66+
if (profiler.length > 0) {
67+
for (let i = 0; i < parametersLength; i++) {
68+
logQuery(invokingResource, query, parseFloat(profiler[i].duration), parameters[i]);
69+
}
70+
}
6571

6672
connection.release();
6773

0 commit comments

Comments
 (0)