Closed Bug 453743 Opened 16 years ago Closed 16 years ago

Decrease the number of calls to the DB about flags when viewing a bug

Categories

(Bugzilla :: Attachments & Requests, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.2

People

(Reporter: LpSolit, Assigned: LpSolit)

References

()

Details

(Keywords: perf)

Attachments

(4 files)

When viewing a bug, Bugzilla::Flag->match() is called once per bug flag type (including inactive ones!), and once per attachment (including those which are not patches), which represents a pretty large number of calls, see the URL. With my patch, this number decreases to only two calls per bug!
Attachment #336953 - Flags: review?(justdave)
Attachment #336953 - Flags: review+
Comment on attachment 336953 [details] [diff] [review]
patch for 3.2, v1

This is totally fine as a hack for the branch. Upstream, we should add a preload argument or something to get_attachments_by_bug (which should really be using Object::match) and something similar for FlagType or Flag, much like we did for products.
Target Milestone: --- → Bugzilla 3.2
I refactored the code and moved the code to get flag type data into Bugzilla::Flag::_flag_types, which is now called by both $bug->flag_types and $attachment->flag_types. To preload flag type data when calling get_attachments_by_bug(), you have to pass a true value as 2nd argument (I don't want a separate preload() function).
Attachment #337308 - Flags: review?(mkanat)
Attachment #336953 - Flags: review?(justdave)
Attachment #337308 - Flags: review?(mkanat) → review+
Comment on attachment 337308 [details] [diff] [review]
patch for tip, v2

Sure, this is fine. However, I'd like the second argument to be { preload => 1} instead of just "1", for the sake of consistency.

Also, it seems like we could be using Bugzilla::Object::match('Bugzilla::Flag', {}) or something here instead of the new _flag_types method, but perhaps for the future.
Flags: approval3.2+
Flags: approval+
tip:

Checking in attachment.cgi;
/cvsroot/mozilla/webtools/bugzilla/attachment.cgi,v  <--  attachment.cgi
new revision: 1.147; previous revision: 1.146
done
Checking in Bugzilla/Attachment.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Attachment.pm,v  <--  Attachment.pm
new revision: 1.57; previous revision: 1.56
done
Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.259; previous revision: 1.258
done
Checking in Bugzilla/Flag.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Flag.pm,v  <--  Flag.pm
new revision: 1.98; previous revision: 1.97
done
Checking in template/en/default/attachment/edit.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/attachment/edit.html.tmpl,v  <--  edit.html.tmpl
new revision: 1.53; previous revision: 1.52
done


3.2rc1:

Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.241.2.10; previous revision: 1.241.2.9
done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
I have to exclude flags related to private attachments you cannot see.

Checking in Bugzilla/Attachment.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Attachment.pm,v  <--  Attachment.pm
new revision: 1.59; previous revision: 1.58
done
Same fix, but for 3.2.

Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.241.2.11; previous revision: 1.241.2.10
done
Attachment #336953 - Attachment description: patch, v1 → patch for 3.2, v1
Attachment #337308 - Attachment description: patch, v2 → patch for tip, v2
Attachment #337569 - Attachment description: fix bustage → fix bustage on tip
Selenium script needed to prevent error due to comment 5.
Flags: testcase?
Flags: testcase?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: