mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 22:21:51 +00:00
refactor(logger): non-debug query profiling
Use less precise query profiling (script based, rather than sql server based). Re-enables slow query warning, and reduces overhead when ui is enabled.
This commit is contained in:
1 parent
d0683b7f30
commit
e31d84019e
4 files changed
+30
-14
No files matched your search
@@ -6,6 +6,7 @@ import type { CFXCallback, CFXParameters } from '../types';
|
||||
import type { QueryType } from '../types';
|
||||
import { getPoolConnection } from './connection';
|
||||
import { RowDataPacket } from 'mysql2';
|
||||
import { performance } from 'perf_hooks';
|
||||
|
||||
export const rawQuery = async (
|
||||
type: QueryType,
|
||||
@@ -28,6 +29,7 @@ export const rawQuery = async (
|
||||
|
||||
try {
|
||||
const hasProfiler = await runProfiler(connection, invokingResource);
|
||||
const startTime = !hasProfiler && performance.now();
|
||||
const [result] = await connection.query(query, parameters);
|
||||
|
||||
if (hasProfiler) {
|
||||
@@ -35,7 +37,9 @@ export const rawQuery = async (
|
||||
await connection.query('SELECT FORMAT(SUM(DURATION) * 1000, 4) AS `duration` FROM INFORMATION_SCHEMA.PROFILING')
|
||||
);
|
||||
|
||||
if (profiler[0]) logQuery(invokingResource, query, profiler[0].duration, parameters);
|
||||
if (profiler[0]) logQuery(invokingResource, query, parseFloat(profiler[0].duration), parameters);
|
||||
} else if (startTime) {
|
||||
logQuery(invokingResource, query, performance.now() - startTime, parameters);
|
||||
}
|
||||
|
||||
if (cb)
|
||||
|
||||
Reference in new issue
Block a user