[db] Missing Index for Transactions Polling#158
Draft
onelapahead wants to merge 3 commits intohyperledger:mainfrom
Draft
[db] Missing Index for Transactions Polling#158onelapahead wants to merge 3 commits intohyperledger:mainfrom
onelapahead wants to merge 3 commits intohyperledger:mainfrom
Conversation
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Chengxuan
reviewed
Mar 3, 2026
Contributor
Chengxuan
left a comment
There was a problem hiding this comment.
For DB index changes, please remember to share the following information:
- migration time ( an example of a DB with a large volume of transactions would be helpful guidance)
- metrics of the benefit that's provided by the new index.
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In transaction managers with a large number of transactions (successful, failed, or pending) we observed large total query times and table scans:
And if we did an explain on one of the more frequent queries from the
policyloop.gowhen there no more pending transactions, but a large number of successful/failed transactions:This confirmed we were doing full table scans on the following query (3k total minutes, 1.6 million calls):
Additionally, another query:
also hits the same problem accounting another ~450 minutes of our query time spent.
Additional queries from the enterprise downstream engine, also highlights this need and accounts for the rest of the query time.
The
order by seqwe apply, means thestatusindex alone is rarely providing the value needed. We are mainly just usingtransaction_pkeyindex, and then doing full table scans, otherwise iftransaction_statusis used, we have to then sort.So by indexing both together, we optimize for the main
policyloop.goquery, and provide a better starting point for all other transaction related queries.