Opened 8 years ago
Closed 8 years ago
#12609 closed defect (fixed)
admin/ticket/milestones and Roadmap pages slow
Reported by: | Owned by: | Jun Omae | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.14 |
Component: | admin/web | Version: | 1.0.13 |
Severity: | normal | Keywords: | performance milestone |
Cc: | Branch: | ||
Release Notes: |
Improved performance of roadmap and milestone admin pages when many milestones and tickets exist. |
||
API Changes: | |||
Internal Changes: |
Description
The admin/ticket/milestones and Roadmap pages take several minutes to load, as we have ~16000 tickets and a couple of hundred milestones.
Is it possible to customise those two pages such that it does not search through all tickets, just to edit or delete a milestone?
Attachments (0)
Change History (13)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Okay. Trac executes SELECT COUNT(*) ...
query for each milestone.
Could you try the following patch?
-
trac/ticket/admin.py
diff --git a/trac/ticket/admin.py b/trac/ticket/admin.py index acd9d4ec5..5072c6196 100644
a b class MilestoneAdminPanel(TicketAdminPanel): 325 325 req.redirect(req.href.admin(cat, page)) 326 326 327 327 # Get ticket count 328 milestones = [ 329 (milestone, self.env.db_query(""" 330 SELECT COUNT(*) FROM ticket WHERE milestone=%s 331 """, (milestone.name,))[0][0]) 332 for milestone in model.Milestone.select(self.env)] 328 counts = dict(self.env.db_query(""" 329 SELECT milestone, COUNT(milestone) FROM ticket 330 WHERE milestone != '' 331 GROUP BY milestone 332 """)) 333 milestones = [(milestone, counts.get(milestone.name, 0)) 334 for milestone in model.Milestone.select(self.env)] 333 335 334 336 data = {'view': 'list', 335 337 'milestones': milestones,
comment:3 by , 8 years ago
Component: | roadmap → admin/web |
---|---|
Keywords: | performance milestone added |
Milestone: | → 1.0.14 |
follow-up: 5 comment:4 by , 8 years ago
That change looks good. I was thinking about #11018, and the possibility that the milestone field could contain either NULL or the empty string, for installations created prior to 1.0.3 (values are now stored as NULL rather than the empty string, but we didn't attempt to fixup instances of the empty string). Based on evaluation with SQLite though, it looks like WHERE milestone != ''
will filter out NULL and empty string entries in the database, which I think is the desired behavior. Can it be expected that any SQL comparison x != ''
will evaluate to true if x is NULL or an empty string?
follow-up: 12 comment:5 by , 8 years ago
Replying to Ryan J Ollos:
Can it be expected that any SQL comparison
x != ''
will evaluate to true if x is NULL or an empty string?
The x != ''
on any databases must not evaluate to true if x is NULL or an empty string. This behavior is based on SQL standard.
x 's value | result of x != ''
|
---|---|
'blah' | True |
'' (an empty string) | False |
NULL | Unknown |
See also:
follow-up: 8 comment:6 by , 8 years ago
The patch makes things MUCH better, i.e. ~5min → ~15sec
Can you do something similar for the roadmap page?
comment:8 by , 8 years ago
Replying to Jeffrey.Ratcliffe@…:
The patch makes things MUCH better, i.e. ~5min → ~15sec
Thanks for the feedback.
Can you do something similar for the roadmap page?
I noticed the roadmap page has a similar issue. I'm creating a patch for it.
follow-up: 11 comment:10 by , 8 years ago
The patch for the roadmap also makes this much better - but only if I disable the simplemultiprojectplugin.
comment:11 by , 8 years ago
Owner: | set to |
---|---|
Release Notes: | modified (diff) |
Status: | new → assigned |
The patch for the roadmap also makes this much better
Thanks. I'm going to apply the changes to 1.0-stable branch.
but only if I disable the simplemultiprojectplugin.
That is an issue of the plugin. Please report to maintainers of the plugin on trac-hacks.org.
comment:12 by , 8 years ago
Replying to Jun Omae:
The
x != ''
on any databases must not evaluate to true if x is NULL or an empty string. This behavior is based on SQL standard.
Thank you for the explanation and references.
comment:13 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Committed in [15192] and merged in [15193,15194].
get_num_tickets_for_milestone
method is introduced in [15078] (1.2dev) however it leads the same issue. Use of the method has been removed in [15193].
What database are you using?