-
Notifications
You must be signed in to change notification settings - Fork 505
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
services/horizon: Batch Upsert Accounts and Trust Lines #2073
services/horizon: Batch Upsert Accounts and Trust Lines #2073
Conversation
@@ -217,7 +219,8 @@ func (p *DatabaseProcessor) ProcessLedger(ctx context.Context, store *pipeline.S | |||
// Get all transactions | |||
var transactions []io.LedgerTransaction | |||
for { | |||
transaction, err := r.Read() | |||
var transaction io.LedgerTransaction | |||
transaction, err = r.Read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like staticcheck
was upgraded (from 20190621195816-6e04913cbbac
to 20191218040434-6f9e13bbec44
). This is a fix for shadowed err
.
sql := ` | ||
WITH r AS | ||
(SELECT | ||
unnest(?::text[]), /* account_id */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartekn LGTM!
services/horizon/internal/expingest/processors/database_processor.go
Outdated
Show resolved
Hide resolved
…sor.go Co-Authored-By: Adolfo Builes <builes.adolfo@gmail.com>
…n/go into batch-upsert-accounts-trust-lines
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
This commit changes
DatabaseProcessor
to insert/update (upsert) accounts and trust lines in batches.Why
In #2004 we added
LedgerEntryChangeCache
that aims to decrease number of DB updates: all the changes connected to a single ledger entry are squashed into just one DB query. Even though it gives a nice performance boost when large number of ops change a small number of ledger entries, it turns out this is not enough. When many ledger entries are changed in a new ledger, DB connection round trip time takes significant percentage of time in overall ledger processing time.The SQL query was borrowed from stellar-core.
Known limitations