Remove redundant good_jobs.active_job_id
index
#1181
Merged
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.
Try running active_record_doctor on a project with GoodJob migrations:
bundle exec rake active_record_doctor
You'll see this output:
remove the index index_good_jobs_on_active_job_id from the table good_jobs - queries should be able to use the following index instead: index_good_jobs_on_active_job_id_and_created_at
This change removes the single column index on 'active_job_id'
A query that used that index before could instead use the existing multicolumn index on
['active_job_id', 'created_at'], where ‘active_job_id’ is also the “leading” column.
The single column index is not a unique index that enforces a unique constraint.
So the single column appears redundant given the multicolumn index with the same leading column, which means it could be removed.