Skip to content

Drop redundant leading-column indexes and index dead_letters.retried_message_id - #117

Closed
cardmagic wants to merge 1 commit into
mainfrom
cloving/task-50aa6364b7bf
Closed

cardmagic wants to merge 1 commit into
mainfrom
cloving/task-50aa6364b7bf

Conversation

@cardmagic

Copy link
Copy Markdown
Owner

Summary

Applications that run Solid Objects on SQLite, PostgreSQL, or MySQL, and the message pruner that deletes old messages, are affected. A new migration that can be reversed drops six duplicate plain indexes and adds an index on dead_letters.retried_message_id. The change is in the new migration in db/migrate, two new schema tests under test/models, and CHANGELOG.md.

The change takes effect when an existing install copies and runs the migration, or when a new install applies the full migration set. Each insert and delete updated two indexes for one access path, and each deleted message caused a scan of dead_letters on SQLite and PostgreSQL.

Verification: The new tests passed on SQLite, PostgreSQL, mysql2, and trilogy, and the full suites failed only on one macOS-only gem type-check test that does not use the schema.

Related: #115

Six plain indexes from t.references repeat the leading column of a
unique index on the same table. Every insert and delete updated both
b-trees, and the unique index serves the same queries. The new
migration drops them and keeps the unique indexes.

dead_letters.retried_message_id has a foreign key with ON DELETE SET
NULL, but SQLite and PostgreSQL had no index on it. Each deleted
message caused a scan of dead_letters, so pruning slowed as dead
letters accumulated. The migration adds
idx_so_dead_letters_retried_message when no index on that column
exists. MySQL already has one for the foreign key, so it gets no
second index.

A schema test fails on a plain index that repeats the leading columns
of a unique index. Its allowlist names the two known indexes on
messages and reminders. A migration test reverts and applies the
migration again on the database under test, and checks that each
MySQL foreign key keeps a covering index.

Refs #115
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR removes six duplicate plain indexes and adds an index on dead_letters.retried_message_id when one does not already exist.

  • Message pruning can find retry links through a new index.
  • Message tables keep one index for each repeated lookup path.

No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "perf: drop redundant indexes and index r..." · Reviewed by Greptile

@context7

context7 Bot commented Dec 2, 2026

Copy link
Copy Markdown

Docs7 for cardmagic/solid-objects-ruby

Result Status Action
Deployment ➖ Not used —
Content review ✅ Passed. No problems found. —

Commit 60216c3

@cardmagic

Copy link
Copy Markdown
Owner Author

Duplicate of #116, which already merged.

@cardmagic cardmagic closed this Dec 2, 2026
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