From 156db134066137e83e780a4e67dd28088b33e386 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 19 May 2022 12:15:21 -0700 Subject: [PATCH] services/horizon: Optimize claimable balances query to limit records earlier (#4385) --- services/horizon/CHANGELOG.md | 4 ++++ services/horizon/internal/db2/history/claimable_balances.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index a43b8ea64f..5cf19852ec 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +- Querying claimable balances has been optimized ([4385](https://github.com/stellar/go/pull/4385)). + ## V2.17.0 This is the final release after the [release candidate](v2.17.0-release-candidate), including some small additional changes: diff --git a/services/horizon/internal/db2/history/claimable_balances.go b/services/horizon/internal/db2/history/claimable_balances.go index f5eb663828..809fb7942a 100644 --- a/services/horizon/internal/db2/history/claimable_balances.go +++ b/services/horizon/internal/db2/history/claimable_balances.go @@ -220,7 +220,7 @@ func (q *Q) GetClaimableBalances(ctx context.Context, query ClaimableBalancesQue sql = sql. Prefix("WITH cb AS ("). Suffix( - ") select "+claimableBalancesSelectStatement+" from cb LIMIT ?", + "LIMIT ?) select "+claimableBalancesSelectStatement+" from cb", query.PageQuery.Limit, )