From d674e03ae201618c6ad970fb2e8c166eb624e3aa Mon Sep 17 00:00:00 2001 From: Vladimir Gorkavenko <32727352+vgorkavenko@users.noreply.github.com> Date: Wed, 5 Apr 2023 15:08:30 +0500 Subject: [PATCH] fix: too wide queries with withdrawals (#150) --- src/storage/clickhouse/clickhouse.constants.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/storage/clickhouse/clickhouse.constants.ts b/src/storage/clickhouse/clickhouse.constants.ts index 3e58eeae..afe73993 100644 --- a/src/storage/clickhouse/clickhouse.constants.ts +++ b/src/storage/clickhouse/clickhouse.constants.ts @@ -33,6 +33,7 @@ export const avgValidatorBalanceDelta = (epoch: Epoch): string => ` FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch > (${epoch} - 6) AND epoch <= ${epoch} LIMIT 1 BY epoch, val_id ) @@ -75,6 +76,7 @@ export const validatorQuantile0001BalanceDeltasQuery = (epoch: Epoch): string => FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch > (${epoch} - 6) AND epoch <= ${epoch} LIMIT 1 BY epoch, val_id ) @@ -117,6 +119,7 @@ export const validatorsCountWithNegativeDeltaQuery = (epoch: Epoch): string => ` FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch > (${epoch} - 6) AND epoch <= ${epoch} LIMIT 1 BY epoch, val_id ) @@ -325,6 +328,7 @@ export const totalBalance24hDifferenceQuery = (epoch: Epoch): string => ` FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch > (${epoch} - 225) AND epoch <= ${epoch} LIMIT 1 BY epoch, val_id ) @@ -368,6 +372,7 @@ export const operatorBalance24hDifferenceQuery = (epoch: Epoch): string => ` FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch > (${epoch} - 225) AND epoch <= ${epoch} LIMIT 1 BY epoch, val_id ) @@ -611,6 +616,7 @@ export const userNodeOperatorsRewardsAndPenaltiesStats = (epoch: Epoch): string FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch = ${epoch} LIMIT 1 BY val_id ) @@ -707,6 +713,7 @@ export const userNodeOperatorsWithdrawalsStats = (epoch: Epoch): string => ` FROM validators_summary WHERE val_nos_id IS NOT NULL AND + val_balance_withdrawn > 0 AND epoch = ${epoch} LIMIT 1 BY val_id ) @@ -748,6 +755,7 @@ export const otherChainWithdrawalsStats = (epoch: Epoch): string => ` FROM validators_summary WHERE val_nos_id IS NULL AND + val_balance_withdrawn > 0 AND epoch = ${epoch} LIMIT 1 BY val_id )