-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
711b647
commit ebfd095
Showing
7 changed files
with
123 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SELECT | ||
chain, | ||
COUNT() AS count, | ||
COUNTDISTINCT(block_number) AS count_distinct, | ||
MAX(block_number) AS max, | ||
MIN(block_number) AS min, | ||
max - min + 1 AS delta, | ||
delta - count_distinct AS missing | ||
FROM blocks | ||
GROUP BY chain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
SELECT | ||
table, | ||
sum(rows) AS rows, | ||
max(modification_time) AS latest_modification, | ||
formatReadableSize(sum(bytes)) AS data_size, | ||
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) | ||
WHERE active | ||
GROUP BY | ||
database, | ||
table | ||
ORDER BY bytes_size DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { z } from "zod"; | ||
import client from "../clickhouse/createClient.js"; | ||
|
||
export const ClusterSchema = z.object({ | ||
count: z.number(), | ||
distinctCount: z.number(), | ||
min: z.number(), | ||
max: z.number(), | ||
delta: z.number(), | ||
missing: z.number(), | ||
}); | ||
export type ClusterSchema = z.infer<typeof ClusterSchema>; | ||
|
||
export async function cluster() { | ||
const query = await Bun.file(import.meta.dirname + "/cluster.sql").text() | ||
const response = await client.query({ query, format: "JSONEachRow" }); | ||
return response.json(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters