-
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 - Media Table #1126
Conversation
@@ -50,7 +50,7 @@ def doi_id=(value) | |||
|
|||
def set_defaults | |||
current_media = | |||
Media.where(dataset: dataset).order("media.created DESC").first | |||
Media.where(dataset: dataset).order("created DESC").first |
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.
Specifying a table name is only necessary on complex queries, simple queries like this one you can just specify the column as there is no ambiguity as to where the column belongs
@@ -1874,7 +1874,7 @@ def metadata_version | |||
end | |||
|
|||
def current_media | |||
media.order("media.created DESC").first |
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.
This is already defined in the association has_many :media, -> { order "created DESC" }..
as a result it produces a query like this "SELECT `media`.* FROM `media` WHERE `media`.`dataset` = 38 ORDER BY created DESC, media.created DESC"
Purpose
We have an incomplete index that is causing the query to do a filesort in the filter. The first part of the query uses index to fetch record but other part is now using filesort.
closes: #1124
Approach
Media
related queriesOpen 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: