Skip to content

Conversation

@yashnevatia
Copy link
Contributor

@yashnevatia yashnevatia commented Jul 9, 2025

HeadTracker insert/deletes are very heavy on the db because its being done per block.
We are trying to batch it here to make it more efficient.

Slack thread -> https://chainlink-core.slack.com/archives/C07PHTC2WJC/p1751473048720999

Ticket:

@yashnevatia yashnevatia requested review from a team as code owners July 9, 2025 15:51
@yashnevatia yashnevatia requested a review from patrickhuie19 July 9, 2025 15:51
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

👋 yashnevatia, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@yashnevatia yashnevatia marked this pull request as draft July 9, 2025 15:51
@yashnevatia yashnevatia changed the title Trim Old Blocks from HeadTracker DB in batches Insert and Trim in Batches for HeadTracker ORM Jul 10, 2025
@yashnevatia yashnevatia marked this pull request as ready for review July 10, 2025 10:44
pkg/heads/orm.go Outdated
for i, head := range heads {
offset := i * 7
placeholders = append(placeholders,
fmt.Sprintf("($%d, $%d, $%d, now(), $%d, $%d, $%d, $%d)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems error-prone. It might be better to use NamedExecContext. Example:

ON CONFLICT DO NOTHING`

dhaidashenko
dhaidashenko previously approved these changes Jul 10, 2025
@yashnevatia yashnevatia merged commit ea9dd76 into develop Jul 10, 2025
35 checks passed
@yashnevatia yashnevatia deleted the head_tracker_batch_trim branch July 10, 2025 13:44
yashnevatia added a commit that referenced this pull request Jul 15, 2025
yashnevatia added a commit that referenced this pull request Jul 15, 2025
* Revert "Insert and Trim in Batches for HeadTracker ORM (#141)"

This reverts commit ea9dd76.

* revert

* t.context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants