Closed Bug 413772 Opened 17 years ago Closed 16 years ago

Eliminate sqlify_criteria in Bugzilla::Flag and replace match() there with Bugzilla::Object::match

Categories

(Bugzilla :: Attachments & Requests, enhancement, P3)

3.1.2
enhancement

Tracking

()

RESOLVED FIXED
Bugzilla 3.2

People

(Reporter: mkanat, Assigned: mkanat)

References

Details

Attachments

(1 file, 1 obsolete file)

Right now bmo has this query about 34 times per second:

SELECT id FROM flags WHERE 1 = 1 AND attach_id IS NULL AND type_id = ? AND bug_id = ?

The first step to fixing that is to remove Bugzilla::Flag::match and replace it with the standard Bugzilla::Object::match, and remove sqlify_criteria in the process.
Attached patch v1 (obsolete) — Splinter Review
Okay, here we go. This was pretty straightforward. Combined with the changes I made to match() in bug 372795, this should be a nice DB performance win, or at least allow us to better diagnose where problems are coming from. Also, it helps clean up the architecture!
Assignee: attach-and-request → mkanat
Status: NEW → ASSIGNED
Attachment #298837 - Flags: review?(LpSolit)
Priority: -- → P3
Target Milestone: --- → Bugzilla 3.2
Comment on attachment 298837 [details] [diff] [review]
v1

>Index: Bugzilla/Flag.pm

>+    return $class->SUPER::match(@_);

This doesn't work. Changing a bug flag throws:

Can't call method "SUPER::match" on unblessed reference at Bugzilla/Flag.pm line 219.



>@@ -1128,51 +1126,6 @@
> # Private Functions
> ######################################################################

Please remove this now useless title.
Attachment #298837 - Flags: review?(LpSolit) → review-
I'm pretty sure the reason of the failure is that Bugzilla::Flag::snapshot() calls match() directly. So you need to write something like:

    my $invocant = shift;
    my $class = ref($invocant) || $invocant;

in match(). Maybe in count() too, btw, to be safe.
Attached patch v2Splinter Review
Okay, there was a limit to how far I was willing to go in converting "::" methods to "->" methods, so for some things here I just used __PACKAGE__ (which makes it hard to subclass Bugzilla::Flag, but you really couldn't do that before anyway).
Attachment #298837 - Attachment is obsolete: true
Attachment #299878 - Flags: review?(LpSolit)
Comment on attachment 299878 [details] [diff] [review]
v2

>+        my $has_flags = __PACKAGE__->count(

No, that's not how I want to see it implemented, especially for process() and snapshot(). All you have to do is to replace direct calls to count() in Flag.pm by Bugzilla::Flag->count() AFAIK.
Attachment #299878 - Flags: review?(LpSolit) → review-
(In reply to comment #5)
> No, that's not how I want to see it implemented, especially for process() and
> snapshot(). All you have to do is to replace direct calls to count() in Flag.pm
> by Bugzilla::Flag->count() AFAIK.

  That's what I *did*. That's what __PACKAGE__->count means. It just doesn't have to be updated if the name of the package changes for some reason--it's the standard Perl way of doing this.
Attachment #299878 - Flags: review- → review?(LpSolit)
Comment on attachment 299878 [details] [diff] [review]
v2

Looks good. r=LpSolit

I'm going to commit it myself as I have another patch conflicting with it.
Attachment #299878 - Flags: review?(LpSolit) → review+
Flags: approval+
Checking in attachment.cgi;
/cvsroot/mozilla/webtools/bugzilla/attachment.cgi,v  <--  attachment.cgi
new revision: 1.141; previous revision: 1.140
done
Checking in editusers.cgi;
/cvsroot/mozilla/webtools/bugzilla/editusers.cgi,v  <--  editusers.cgi
new revision: 1.146; previous revision: 1.145
done
Checking in post_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/post_bug.cgi,v  <--  post_bug.cgi
new revision: 1.193; previous revision: 1.192
done
Checking in process_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v  <--  process_bug.cgi
new revision: 1.402; previous revision: 1.401
done
Checking in Bugzilla/Attachment.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Attachment.pm,v  <--  Attachment.pm
new revision: 1.55; previous revision: 1.54
done
Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.231; previous revision: 1.230
done
Checking in Bugzilla/Flag.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Flag.pm,v  <--  Flag.pm
new revision: 1.90; previous revision: 1.89
done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Blocks: 415663
Blocks: 434062
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: