-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add/Remove Indexes - Allocator Table #1118
Conversation
def change | ||
add_index :allocator, :deleted_at, name: "index_allocator_deleted_at" | ||
add_index :allocator, :role_name, name: "index_allocator_role_name" | ||
add_index :allocator, :ror_id, name: "index_allocator_ror_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaysiz have we confirmed that the queries missing these indices are in fact using these indices in the query execution plan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question Wendel!
I think if Rails is not smart enough to have done this and we have to do it manually, it can be a separate piece of work/PR and doesn't need to be a blocker to merging this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool cool. One thing we may notice is we may get a bunch of index scans instead of index seeks. Since the query executor will still need to go back into the table fetch relevant information (columns not included in the index). MySql will only use one index per query per table so index_allocator_deleted_at would be used or index_allocator_role_name will be used or neither if the query executor thinks it's unnecessary.
@kaysiz something for us to keep in mind, adding additional indices will have two side-effects:
Just thought I'd add these as a comment just so we could keep an eye on any write performance degradation or if we see a uptick in RDS storage usage. |
@wendelfabianchinsamy We are doing more reading than writing to the table, we will monitor after deployment if there are any performance issues, but this should improve our read speed. |
|
||
class RemoveGlobusUuidIndex < ActiveRecord::Migration[6.1] | ||
def change | ||
remove_index :allocator, column: :globus_uuid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we might need this index, because we are using this column in serializer at many places, you can take a look at this commit for reference eeb811c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashwinisukale unfortunately we are not using the column to fetch any data(that is either .where
, find_by
or order_by
), inside the serialiser it is used to conditionally include the the attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one comment regarding globus_uuid
column index. Otherwise code looks good.
…d-allocator-indexes
Purpose
We have missing and unused indexes on allocator table.
closes: #1117
Approach
Open Questions and Pre-Merge TODOs
Learning
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Reviewer, please remember our guidelines: