Patch #43619
closed
Optimize Issue#recalculate_attributes_for by merging date queries
Added by Go MAEDA 21 days ago.
Updated 19 days ago.
Description
The attached patch slightly improves performance in Issue#recalculate_attributes_for.
When the method recalculates start_date and due_date, two separate queries (MIN(start_date) and MAX(due_date)) are currently executed. This change merges them into a single query, reducing one database round-trip.
Files
- Target version changed from Candidate for next major release to 7.0.0
Setting the target version to 7.0.0.
- Status changed from New to Closed
- Assignee set to Go MAEDA
Committed the patch in r24229.
- Status changed from Closed to Reopened
The change made in r24229 broke tests with PostgreSQL.
Error:
IssueNestedSetTest#test_destroy_parent_issue_updated_during_children_destroy:
ActiveRecord::StatementInvalid: PG::GroupingError: ERROR: column "issues.lft" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ..."issues" WHERE "issues"."parent_id" = $1 ORDER BY "issues"."...
^
app/models/issue.rb:1873:in 'Issue#recalculate_attributes_for'
app/models/issue.rb:1853:in 'Issue#update_parent_attributes'
app/models/issue.rb:248:in 'Issue#create_or_update'
test/object_helpers.rb:107:in 'Issue.generate!'
test/object_helpers.rb:300:in 'IssueObjectHelpers#generate_child!'
test/unit/issue_nested_set_test.rb:276:in 'IssueNestedSetTest#test_destroy_parent_issue_updated_during_children_destroy'
bin/rails test test/unit/issue_nested_set_test.rb:274
Although I cannot reproduce the problem in my development environment, I am going to revert the change.
- Status changed from Reopened to Closed
- Target version deleted (
7.0.0)
Reverted the change in r24230.
Also available in: Atom
PDF