Skip to content

Conversation

@mkysel
Copy link
Collaborator

@mkysel mkysel commented Sep 29, 2025

Our pruner in us-east-2 dev was failing. The prune query was taking more than 5ish minutes.

The index creation here is the same as in 00016 and does not use concurrently, which might eventually become a problem. But so far its the pattern, so I am keeping it going.

@mkysel mkysel requested a review from a team as a code owner September 29, 2025 18:49
@graphite-app
Copy link

graphite-app bot commented Sep 29, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@macroscopeapp
Copy link

macroscopeapp bot commented Sep 29, 2025

Create a partial covering index gateway_envelopes_expiry_idx on gateway_envelopes(expiry) including originator_node_id and originator_sequence_id with statement_timeout set to 0 to speed up pruning

This change adds migrations to manage a partial covering index on gateway_envelopes. The up migration disables session statement_timeout and creates gateway_envelopes_expiry_idx on gateway_envelopes(expiry) including originator_node_id and originator_sequence_id for rows where expiry IS NOT NULL. The down migration drops the index if it exists.

📍Where to Start

Start with the up migration in 00017_prune_index.up.sql to review the index definition and session settings.


Macroscope summarized 116129a.

@mkysel mkysel changed the title Speed up pruner by adding a fully covering index Speed up pruner by adding a partially covering index Sep 29, 2025
Comment on lines +4 to +7
CREATE INDEX gateway_envelopes_expiry_idx
ON gateway_envelopes (expiry)
INCLUDE (originator_node_id, originator_sequence_id)
WHERE expiry IS NOT NULL; No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we create this concurrently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

definitely. But I haven't had the chance to figure out how to do CONCURRENTLY. There is some setting somewhere. Will be worth investigating eventually.

@mkysel mkysel merged commit 06cb109 into main Sep 30, 2025
11 checks passed
@mkysel mkysel deleted the mkysel/prune-index branch September 30, 2025 15:26
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.

3 participants