diff --git a/sql/cluster.sql b/sql/cluster.sql index 73ee7a5..2f2061c 100644 --- a/sql/cluster.sql +++ b/sql/cluster.sql @@ -6,7 +6,7 @@ SELECT formatReadableSize(sum(primary_key_bytes_in_memory)) AS primary_keys_size, any(engine) AS engine, sum(bytes) AS bytes_size -FROM clusterAllReplicas(default, system.parts) +FROM clusterAllReplicas({database: String}, system.parts) WHERE active GROUP BY database, diff --git a/sql/cluster.ts b/sql/cluster.ts index 156dbe5..783431b 100644 --- a/sql/cluster.ts +++ b/sql/cluster.ts @@ -1,5 +1,6 @@ import { z } from "zod"; import { readOnlyClient } from "../src/clickhouse/createClient.js"; +import { config } from "../src/config.js"; export const ClusterSchema = z.object({ count: z.number(), @@ -13,6 +14,6 @@ export type ClusterSchema = z.infer; export async function cluster() { const query = await Bun.file(import.meta.dirname + "/cluster.sql").text() - const response = await readOnlyClient.query({ query, format: "JSONEachRow" }); + const response = await readOnlyClient.query({ query, query_params: {database: config.database}, format: "JSONEachRow" }); return response.json(); }