feat(base): env var for duckdb reader-pool size

This commit is contained in:
Philipinho
2026-04-23 15:52:35 +01:00
parent 709d927544
commit b04bcb5b0c
2 changed files with 18 additions and 0 deletions
@@ -10,6 +10,7 @@ export type QueryCacheConfig = {
threads: number;
trace: boolean;
tempDirectory: string;
readerPoolSize: number;
};
@Injectable()
@@ -25,6 +26,7 @@ export class QueryCacheConfigProvider {
threads: env.getBaseQueryCacheThreads(),
trace: env.getBaseQueryCacheTrace(),
tempDirectory: env.getBaseQueryCacheTempDirectory(),
readerPoolSize: env.getBaseQueryCacheReaderPoolSize(),
};
}
}
@@ -385,4 +385,20 @@ export class EnvironmentService {
10,
);
}
getBaseQueryCacheReaderPoolSize(): number {
// Number of reader connections held open against the shared DuckDB
// instance. Reads are dispatched via `withReader()` which checks out a
// connection, runs the query, returns it. Bigger pool = more concurrent
// reads without serialization, at the cost of per-connection overhead
// (each connection carries its own catalog snapshot + prepared-statement
// cache ~= 300 KB).
//
// Default 4 matches libuv's default thread-pool size. Raise to 8+ if
// you see p99 list latency correlate with concurrent request volume.
return parseInt(
this.configService.get<string>('BASE_QUERY_CACHE_READER_POOL_SIZE', '4'),
10,
);
}
}