镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

db: index blocks(height) references - #9450

Open
JssDWt wants to merge 1 commit into
ElementsProject:masterfrom
JssDWt:jssdwt-missing-indices
Open

JssDWt wants to merge 1 commit into
ElementsProject:masterfrom
JssDWt:jssdwt-missing-indices

Conversation

@JssDWt

@JssDWt JssDWt commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Add missing simple indexes.

Changelog-Fixed: db: much faster startup on postgres nodes with large transactions or channeltxs tables.

Tested on a production node running into the issue described above (fixes it).

@JssDWt
JssDWt force-pushed the jssdwt-missing-indices branch from a15cdef to 7af4635 Compare September 17, 2026 14:36
@JssDWt

JssDWt commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Rebased.

Postgres doesn't index the referencing side of a foreign key, so every
row deleted from `blocks` scans `transactions`, `channeltxs` and
`outputs` in full. Postgres was taking 100% CPU for multiple minutes,
causing startup timeouts in systemd.

247aa13 and 50a8e32 added indices for `outputs` and `utxoset` in
2018. `channeltxs` (28feb2e) and `transactions` (0f89653) arrived
weeks later without one. `outputs` is only half-covered:
`output_height_idx` is (`confirmation_height`, `spend_height`), which
doesn't serve a lookup on `spend_height` alone.

Changelog-Fixed: db: much faster startup on postgres nodes with large `transactions` or `channeltxs` tables.
@JssDWt
JssDWt force-pushed the jssdwt-missing-indices branch from 7af4635 to 4eb1e34 Compare October 1, 2026 18:26
@JssDWt

JssDWt commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased. Any takers? I know you guys are busy. This was a startup hang blocker for us.

This branch has not been deployed

No deployments
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.

1 participant