Skip to content

Commit af0453e

Browse files
carderneTrigger.dev RepoOps
authored andcommitted
perf(webapp): opt-in lazy materialization for the logs list query
Mono-RevId: b56b226a2b7a8428b9cfc6363f41cccf0564b173
1 parent 68ee6be commit af0453e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎apps/webapp/app/env.server.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,10 @@ const EnvironmentSchema = z
23002300
.int()
23012301
.default(256_000_000),
23022302
CLICKHOUSE_LOGS_LIST_MAX_THREADS: z.coerce.number().int().default(2),
2303+
// Logs list only: read the sort columns first and fetch the rest for the final page. Fewer
2304+
// column reads, which matters most on object storage. The settings exist from ClickHouse 25.4,
2305+
// but this query reads in sort order, which blocked lazy materialization until 25.8. Opt-in.
2306+
CLICKHOUSE_LOGS_LIST_LAZY_MATERIALIZATION: BoolEnv.default(false),
23032307
// The HTTP request timeout is derived from this so ClickHouse gives up before the client does.
23042308
CLICKHOUSE_LOGS_LIST_MAX_EXECUTION_TIME: z.coerce.number().int().default(15),
23052309
// Bound read-in-order memory on object-storage reads: each part opens a per-column read

‎apps/webapp/app/presenters/v3/LogsListPresenter.server.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,16 @@ export class LogsListPresenter extends BasePresenter {
261261
// Run exactly one bounded query. Broadening a search window is an explicit user action;
262262
// silently rescanning the same recent rows makes absence queries needlessly expensive.
263263
const runQuery = () => {
264-
const queryBuilder = this.clickhouse.taskEventsSearch.logsListQueryBuilder();
264+
const queryBuilder = this.clickhouse.taskEventsSearch.logsListQueryBuilder({
265+
// Scoped to this query rather than the logs client, which other pages share. ClickHouse
266+
// skips lazy materialization when LIMIT exceeds the max, so pass this query's limit.
267+
settings: env.CLICKHOUSE_LOGS_LIST_LAZY_MATERIALIZATION
268+
? {
269+
query_plan_optimize_lazy_materialization: 1,
270+
query_plan_max_limit_for_lazy_materialization: queryLimit,
271+
}
272+
: undefined,
273+
});
265274

266275
// The projector excludes events without a trace_id.
267276
queryBuilder.where("trace_id != ''");

0 commit comments

Comments
 (0)