-
Notifications
You must be signed in to change notification settings - Fork 145
Improve schema check and push latency for conditional breaking changes #8190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'hive': patch | ||
| --- | ||
|
|
||
| Improve performance of schema checks by using a table with an ordering that more closely aligns with | ||
| the query for total request count for a target" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1013,6 +1013,13 @@ export class OperationsReader { | |
| .tuple([z.object({ amountOfRequests: z.string() })]) | ||
| .transform(data => ensureNumber(data[0].amountOfRequests)); | ||
|
|
||
| /** | ||
| * This is using clients_daily instead of operations_daily because the | ||
| * order by is more favorable in clients_daily since the client_name is | ||
| * right after target. However, this could be better without storing | ||
| * much more data, by creating another materialized view ordered by | ||
| * target, timestamp, then client_name. | ||
| */ | ||
|
Comment on lines
+1016
to
+1022
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When
We should conditionally select from const useClientsDaily = !!(args.excludedClients && args.excludedClients.length > 0);
const table = sql.raw(useClientsDaily ? 'clients_daily' : 'operations_daily');
/**
* This is using clients_daily instead of operations_daily because the
* order by is more favorable in clients_daily since the client_name is
* right after target. However, this could be better without storing
* much more data, by creating another materialized view ordered by
* target, timestamp, then client_name.
*/References
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. operations_daily uses: clients_daily uses: There are potentially many hash. If we can filter by the client_name immediately, then this is clearly a win. Idk what this AI comment is talking about. I'm also choosing to not use operations_daily because |
||
| return await this.clickHouse | ||
| .query<unknown>({ | ||
| queryId: 'getTotalCountForSchemaCoordinates', | ||
|
|
@@ -1021,14 +1028,14 @@ export class OperationsReader { | |
| SUM("result"."total") AS "amountOfRequests" | ||
| FROM ( | ||
| SELECT | ||
| SUM("operations_daily"."total") AS "total" | ||
| SUM("clients_daily"."total") AS "total" | ||
| FROM | ||
| "operations_daily" | ||
| "clients_daily" | ||
| PREWHERE | ||
| "operations_daily"."target" IN (${sql.array(args.targetIds, 'String')}) | ||
| AND "operations_daily"."timestamp" >= toDateTime(${formatDate(args.period.from)}, 'UTC') | ||
| AND "operations_daily"."timestamp" <= toDateTime(${formatDate(args.period.to)}, 'UTC') | ||
| ${args.excludedClients ? sql`AND "operations_daily"."client_name" NOT IN (${sql.array(args.excludedClients, 'String')})` : sql``} | ||
| "clients_daily"."target" IN (${sql.array(args.targetIds, 'String')}) | ||
| AND "clients_daily"."timestamp" >= toDateTime(${formatDate(args.period.from)}, 'UTC') | ||
| AND "clients_daily"."timestamp" <= toDateTime(${formatDate(args.period.to)}, 'UTC') | ||
| ${args.excludedClients ? sql`AND "clients_daily"."client_name" NOT IN (${sql.array(args.excludedClients, 'String')})` : sql``} | ||
|
jdolle marked this conversation as resolved.
Outdated
|
||
|
|
||
| UNION ALL | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.