Skip to content
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

fix: change all HASH indexes to BTREE to optimize writes #1825

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

rafaelcr
Copy link
Collaborator

Our HASH indexes did not have enough cardinality, i.e. there were a lot of collisions which forced postgres to create "secondary" indexes of data inside each of those collisions. Changing indexes to BTREE helped reduce write latency tremendously (from ~5-10 seconds per block to ~150-900ms per block.

Copy link

github-actions bot commented Jan 12, 2024

Vercel deployment URL: https://stacks-blockchain-76kamf52i-blockstack.vercel.app 🚀

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5505d35) 71.71% compared to head (06d926b) 71.72%.
Report is 1 commits behind head on beta.

Additional details and impacted files
@@           Coverage Diff           @@
##             beta    #1825   +/-   ##
=======================================
  Coverage   71.71%   71.72%           
=======================================
  Files          91       91           
  Lines       11835    11835           
  Branches     2622     2622           
=======================================
+ Hits         8488     8489    +1     
+ Misses       3194     3193    -1     
  Partials      153      153           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rafaelcr rafaelcr merged commit 234936b into beta Jan 12, 2024
30 checks passed
@rafaelcr rafaelcr deleted the fix/index-optim branch January 12, 2024 23:24
blockstack-devops pushed a commit that referenced this pull request Jan 12, 2024
## [7.8.0-beta.3](v7.8.0-beta.2...v7.8.0-beta.3) (2024-01-12)

### Bug Fixes

* change all HASH indexes to BTREE to optimize writes ([#1825](#1825)) ([234936b](234936b))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.8.0-beta.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Jan 23, 2024
## [7.8.0](v7.7.2...v7.8.0) (2024-01-23)

### Features

* add `/extended/v2/smart-contracts/status` endpoint ([#1833](#1833)) ([3535c11](3535c11))
* run inserts in batch and in parallel when processing new block ([#1818](#1818)) ([86dfdb5](86dfdb5))
* upgrade to node 20, use bookworm-slim image ([#1832](#1832)) ([0a42109](0a42109))

### Bug Fixes

* change all HASH indexes to BTREE to optimize writes ([#1825](#1825)) ([234936b](234936b))
* log block event counts after processing ([#1820](#1820)) ([9c39743](9c39743)), closes [#1819](#1819) [#1819](#1819)
* optimize re-org queries and indexes ([#1821](#1821)) ([5505d35](5505d35))
* parallelize re-org update queries ([#1835](#1835)) ([340a304](340a304))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants