From 98ef8800e2b7ce530aa671b606668440deab9c45 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Thu, 19 May 2022 11:38:24 -0700 Subject: [PATCH] Move LIMIT to WITH clause --- 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, )