Project

General

Profile

Actions

Patch #43619

closed

Optimize Issue#recalculate_attributes_for by merging date queries

Added by Go MAEDA 21 days ago. Updated 19 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
-
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

merge-two-date-queries.patch (626 Bytes) merge-two-date-queries.patch Go MAEDA, 2025-12-22 05:10
Actions #1

Updated by Go MAEDA 20 days ago

  • Target version changed from Candidate for next major release to 7.0.0

Setting the target version to 7.0.0.

Actions #2

Updated by Go MAEDA 19 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch in r24229.

Actions #3

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 #4

Updated by Go MAEDA 19 days ago

  • Status changed from Reopened to Closed
  • Target version deleted (7.0.0)

Reverted the change in r24230.

Actions

Also available in: Atom PDF