mirror of
https://github.com/docmost/docmost.git
synced 2026-05-06 22:03:06 +08:00
ms
This commit is contained in:
@@ -27,6 +27,8 @@ export class BaseQueryRouter {
|
|||||||
async decide(args: RouteDecideArgs): Promise<RouteDecision> {
|
async decide(args: RouteDecideArgs): Promise<RouteDecision> {
|
||||||
const { enabled, minRows } = this.configProvider.config;
|
const { enabled, minRows } = this.configProvider.config;
|
||||||
const trace = this.configProvider.config.trace ?? false;
|
const trace = this.configProvider.config.trace ?? false;
|
||||||
|
const debug = this.env?.getBaseQueryCacheDebug() ?? false;
|
||||||
|
const tStart = debug ? Date.now() : 0;
|
||||||
|
|
||||||
const emit = (route: RouteDecision, reason: string): RouteDecision => {
|
const emit = (route: RouteDecision, reason: string): RouteDecision => {
|
||||||
if (trace) {
|
if (trace) {
|
||||||
@@ -57,9 +59,10 @@ export class BaseQueryRouter {
|
|||||||
|
|
||||||
// Fast path: if the collection is already resident, read the cached
|
// Fast path: if the collection is already resident, read the cached
|
||||||
// row count instead of running a Postgres COUNT on every request.
|
// row count instead of running a Postgres COUNT on every request.
|
||||||
|
const tPeek = debug ? Date.now() : 0;
|
||||||
const resident = this.cacheService.peek(args.baseId);
|
const resident = this.cacheService.peek(args.baseId);
|
||||||
|
const peekMs = debug ? Date.now() - tPeek : 0;
|
||||||
if (resident) {
|
if (resident) {
|
||||||
const debug = this.env?.getBaseQueryCacheDebug() ?? false;
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
console.log(
|
console.log(
|
||||||
'[cache-perf]',
|
'[cache-perf]',
|
||||||
@@ -68,6 +71,8 @@ export class BaseQueryRouter {
|
|||||||
baseId: args.baseId.slice(0, 8),
|
baseId: args.baseId.slice(0, 8),
|
||||||
count: resident.rowCount,
|
count: resident.rowCount,
|
||||||
minRows,
|
minRows,
|
||||||
|
ms: peekMs,
|
||||||
|
totalMs: Date.now() - tStart,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -83,7 +88,6 @@ export class BaseQueryRouter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const debug = this.env?.getBaseQueryCacheDebug() ?? false;
|
|
||||||
const tCount = debug ? Date.now() : 0;
|
const tCount = debug ? Date.now() : 0;
|
||||||
const count = await this.baseRowRepo.countActiveRows(args.baseId, {
|
const count = await this.baseRowRepo.countActiveRows(args.baseId, {
|
||||||
workspaceId: args.workspaceId,
|
workspaceId: args.workspaceId,
|
||||||
@@ -97,6 +101,8 @@ export class BaseQueryRouter {
|
|||||||
countMs: Date.now() - tCount,
|
countMs: Date.now() - tCount,
|
||||||
count,
|
count,
|
||||||
minRows,
|
minRows,
|
||||||
|
ms: Date.now() - tCount,
|
||||||
|
totalMs: Date.now() - tStart,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user