mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 19:08:04 +01:00
Fix memory usage by batching syncTasks
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import { isNumber, last } from 'lodash';
|
||||
import type { ReadableDB, WritableDB } from './Interface';
|
||||
import type { LoggerType } from '../types/Logging';
|
||||
|
||||
export type EmptyQuery = [];
|
||||
export type ArrayQuery = Array<ReadonlyArray<null | number | bigint | string>>;
|
||||
@@ -162,17 +163,6 @@ export function sql(
|
||||
return [fragment, fragmentParams];
|
||||
}
|
||||
|
||||
type QueryPlanRow = Readonly<{
|
||||
id: number;
|
||||
parent: number;
|
||||
details: string;
|
||||
}>;
|
||||
|
||||
type QueryPlan = Readonly<{
|
||||
query: string;
|
||||
plan: ReadonlyArray<QueryPlanRow>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Returns typed objects of the query plan for the given query.
|
||||
*
|
||||
@@ -189,11 +179,19 @@ type QueryPlan = Readonly<{
|
||||
*/
|
||||
export function explainQueryPlan(
|
||||
db: ReadableDB,
|
||||
logger: LoggerType,
|
||||
template: QueryTemplate
|
||||
): QueryPlan {
|
||||
): QueryTemplate {
|
||||
const [query, params] = template;
|
||||
const plan = db.prepare(`EXPLAIN QUERY PLAN ${query}`).all(params);
|
||||
return { query, plan };
|
||||
logger.info('EXPLAIN QUERY PLAN');
|
||||
for (const line of query.split('\n')) {
|
||||
logger.info(line);
|
||||
}
|
||||
for (const row of plan) {
|
||||
logger.info(`id=${row.id}, parent=${row.parent}, detail=${row.detail}`);
|
||||
}
|
||||
return [query, params];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user