Repository navigation
perf: drop redundant indexes, index dead_letters.retried_message_id - #116
Merged
Merged
Conversation
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; the earlier database comparison issue is fixed. SummaryThe PR drops six covered indexes and adds an index for
Reviews (2) · Last reviewed commit: "test: compare upgrade with fresh install..." · Reviewed by Greptile |
Owner
Author
|
@greptileai review |
|
Docs7 for cardmagic/solid-objects-ruby
Commit |
This was referenced Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New migration
20261202000000_drop_redundant_solid_objects_indexes.rb(reversible):Each dropped index is a plain index whose leading columns already lead a unique index, so inserts and deletes maintained two b-trees for one access path.
dead_letters.retried_message_idhas a foreign key with no index on SQLite and PostgreSQL, so every pruned message scansdead_letters. MySQL already indexes the key, so the migration adds nothing there and never leaves two indexes on the column.index_solid_objects_effects_on_message_idandindex_solid_objects_dead_letters_on_instance_idstay: each is the only index on its column. Down restores the six indexes first, then removes the index this migration added when it is present.Compatibility and migration
Existing installs run
bin/rails solid_objects:install:migrationsanddb:migrate. New installs reach the same index set throughSchemaBootstrap.install. No public API change, no version bump, and shipped migrations are unchanged. This is a minor-release change; the CHANGELOG## Unreleasednote says so.Tests
test/models/redundant_index_schema_test.rb:index_solid_objects_messages_on_instance_idandindex_solid_objects_reminders_on_instance_id(commented as known and left for a possible follow-up), and fails when an allowlisted index no longer exists;idx_so_messages_instance_sequenceandidx_so_messages_idempotencysharinginstance_id, and a scratch table proves the detector does flag a covered index;retried_message_idindex, down and up on the live adapter, and an upgrade of an already-installed SQLite schema ending in the same index set as a fresh install;message_idandinstance_idkeys on every adapter, and for every foreign key on MySQL (mysql2andtrilogyjobs). The MySQL-only test skips on SQLite and PostgreSQL.Before the migration existed, 6 of the 10 tests failed (the six indexes present, the migration missing). Full local run on SQLite: 1030 runs, 0 failures, 40 skips.
rake standard rubocop rbs steep securityis clean. PostgreSQL and MySQL run in CI; neither server was available locally.Closes #115
Merge Danger
Door: two-way (down restores the indexes)
Blast Radius: index set on six tables for installs that run the migration