Actions
Patch #43619
closedOptimize Issue#recalculate_attributes_for by merging date queries
Start date:
Due date:
% Done:
0%
Estimated time:
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
Updated by Go MAEDA 19 days ago
- 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.
Actions