Patch #33431
Better performance for Time entries without issue and activity filters
Status: | New | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 0% | |
Category: | Performance | |||
Target version: | Candidate for next major release |
Description
At the moment all time entry queries join issue and activities. If there is a large number of time entries and issues, this is a big performance issue.
Some of our customers have more than 500.000 time entries and even more issues. A query without a time filter requires minutes. With this attached patch this improves it to some seconds.
Issue and activity joins are only add, if they are required.
It would be great, to get this in Redmine.
History
#1
Updated by Go MAEDA about 2 years ago
- Category changed from Time tracking to Performance
- Target version set to Candidate for next major release
#2
Updated by Go MAEDA about 2 years ago
Looks good to me.
#3
Updated by Alexander Meindl about 2 years ago
My patch has problems with column sort order.
But I found the real problem now. It is a missing condition to project_id for Enumeration. I am working on a new patch to fix this problem. Please do not commit the current patch.
#4
Updated by Marius BALTEANU about 2 years ago
Alexander Meindl wrote:
My patch has problems with column sort order.
But I found the real problem now. It is a missing condition to project_id for Enumeration. I am working on a new patch to fix this problem. Please do not commit the current patch.
Nice feature, but we should have tests for this change.
#5
Updated by Alexander Meindl about 2 years ago
- File time_query_performace_v2.patch
added
Here is my new fixed version.
Adding
where("#{Enumeration.table_name}.project_id = #{TimeEntry.table_name}.project_id")
fixed the problem. But I moved activity join from base_scope to results_scope, because as I understood it, activity join is not required for totals and count.
I am not sure, how I can test this change with an additional test. Existing test should work, of course.
#6
Updated by Alexander Meindl about 2 years ago
- File time_query_performace_v3.patch
added
And again, now all tests are running.
With my test data, /time_entries without filters
- without patch: ActiveRecord: 345038.1ms
- with patch ActiveRecord: 6038.4ms
This is not perfect, but way better than before. At the moment I have no idea how it can be more improved. The problem is table layout of enumerations table.