Doing most anything with the bugs_activity table is interminably slow, because the existing indices don't cover the added/removed fields, which are what really need help the most. For example: running 'collectstats.pl --regenerate' on my local database with these indices took under 5 hours; before putting the indices on, I let it run for 35 hours before I stopped it, and it did not yet look to be more than halfway done. Patch to follow.
Adds indices to existing and new tables; tip version
Attachment #177773 - Flags: review?
Adds indices to existing and new tables; 2.18 version
Attachment #177774 - Flags: review?
Status: NEW → ASSIGNED
Target Milestone: --- → Bugzilla 2.18
Attachment #177773 - Flags: review? → review?(bugreport)
Attachment #177774 - Flags: review? → review?(bugreport)
Comment on attachment 177773 [details] [diff] [review] Code patch for tip r=joel by inspection
Attachment #177773 - Flags: review?(bugreport) → review+
Comment on attachment 177774 [details] [diff] [review] Code patch for 2.18 r=joel by inspection
Attachment #177774 - Flags: review?(bugreport) → review+
travis, assuming you are on vacation this week, I'm commiting this patch myself. ;) Tip: Checking in checksetup.pl; /cvsroot/mozilla/webtools/bugzilla/checksetup.pl,v <-- checksetup.pl new revision: 1.376; previous revision: 1.375 done Checking in Bugzilla/DB/Schema.pm; /cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm,v <-- Schema.pm new revision: 1.15; previous revision: 1.14 done 2.18 branch: Checking in checksetup.pl; /cvsroot/mozilla/webtools/bugzilla/checksetup.pl,v <-- checksetup.pl new revision: 1.289.2.29; previous revision: 1.289.2.28 done
Status: ASSIGNED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED
DBD::mysql::db do failed: Duplicate key name 'bugs_activity_idfield' at ./checksetup.pl line 3873
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Both patche have been backed out. checksetup.pl fails with the following error messages: Tip: Adding more indexes for bugs_activity table. DBD::mysql::db do failed: Duplicate key name 'bugs_activity_idfield' at ./checksetup.pl line 3873 2.18: Adding more indexes for bugs_activity tables. DBD::mysql::db do failed: Duplicate key name 'bugs_activity_idfield' at ./checksetup.pl line 4531. DBD::mysql::db do failed: Duplicate key name 'bugs_activity_added' at ./checksetup.pl line 4532. DBD::mysql::db do failed: Duplicate key name 'bugs_activity_removed' at ./checksetup.pl line 4533. DBD::mysql::db do failed: Duplicate key name 'bugs_activity_added_removed' at ./checksetup.pl line 4534. Moreover, I observe a index name inconsistency: +$dbh->do("ALTER TABLE bugs_activity ADD INDEX bugs_activity_idfield (bug_id, fieldid)"); + bugs_activity_bug_field_idx => [qw(bug_id fieldid)],
Comment on attachment 177773 [details] [diff] [review] Code patch for tip per my previous comment
Comment on attachment 177773 [details] [diff] [review] Code patch for tip Also, could you explain why you're adding three more fulltext indexes? Fulltext indexes will cause us problems in the future, because we can't have transactional (InnoDB) tables with fulltext indexes in them. I don't fully understand why we would be *searching* on added and removed, but I'm sure there's some good reason?
I can see why you would want an index on (fieldid, added) and (fieldid, removed), but I cannot see why those would need to be fulltext. Please try some benchmarks using (fieldid, added) and (fieldid, removed) or, possibly, (fieldid, added, bugid)(fieldid, removed, bugid) or (fieldid, leftmost 10 chars of added), etc....
You know, looking over the general Bugzilla code, and the regenerate option of collectstats, it looks like we just need the following multi-column index to handle the regenerate stuff: bugs_activity(bug_id, bug_when, fieldid) We could then also drop the bug_id index, or just replace it with that one. An examination of Bugzilla code shows me that we should get performance gains elsewhere in Bugzilla with that multi-column index. I don't think that anything else is actually necessary for 2.18.1, at the least. Also, the indexes in the patch on this bug don't include _idx on the end of their name, which they should.
Oh, actually, actual experimentation with EXPLAIN shows that the index created in this bug is actually correct, not the index that I just stated. So the idea index is: bugs_activity(bug_id, fieldid) And we can eliminate the bug_id index, because we can always use that one instead. But that's the only index needed to fix the collectstats problem.
"If it's not a regression from 2.18 and it's not a critical problem with something that's already landed, let's push it off." - Dave
Not a security bug, retargetting to 2.20.
Target Milestone: Bugzilla 2.18 → Bugzilla 2.20
travis has gone, and nothing is broken here, just slow => retargetting
Assignee: shane.h.w.travis → query-and-buglist
Severity: normal → minor
Status: REOPENED → NEW
Whiteboard: [wanted for 2.20]
Target Milestone: Bugzilla 2.20 → Bugzilla 2.24
We are freezing the code for 3.0 in two weeks and we don't expect this bug to be fixed on time.
Target Milestone: Bugzilla 3.0 → ---
Severity: enhancement → minor
Summary: Add more indexes to bugs_activity table → ./collectstats.pl --regenerate is enormously slow
This is a work in progress, including some debugging code. As usual, what is ACTUALLY slow is not what you might think.
This makes --regenerate take minutes instead of hours or days.
This patch also fixes a problem where --regenerate wasn't correctly counting the empty resolution. (I believe normal collectstats.pl also has this bug, and we can address it separately somewhere.)
Target Milestone: --- → Bugzilla 3.6
Comment on attachment 395288 [details] [diff] [review] v1 Nice catch about the empty resolution. Old data is indeed wrong as the number of closed bugs doesn't match the number of bugs having a resolution. Also, the perf improvement is huge. IMO, both are valid reasons to take this patch for 3.4. r=LpSolit
Attachment #395288 - Flags: review?(LpSolit) → review+
Let's take it on the 3.4 branch as it fixes a bug. And the huge perf problem can also be seen as a bug.
tip: Checking in collectstats.pl; /cvsroot/mozilla/webtools/bugzilla/collectstats.pl,v <-- collectstats.pl new revision: 1.70; previous revision: 1.69 done 3.4: Checking in collectstats.pl; /cvsroot/mozilla/webtools/bugzilla/collectstats.pl,v <-- collectstats.pl new revision: 220.127.116.11; previous revision: 18.104.22.168 done
Status: ASSIGNED → RESOLVED
Last Resolved: 14 years ago → 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.