Commit 657f495a authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 577754: Make updating bugs_fulltext during checksetup.pl WAY faster

for MySQL. r=mkanat, a=mkanat (module owner)
parent 8bdb86fd
...@@ -3182,20 +3182,29 @@ sub _populate_bugs_fulltext { ...@@ -3182,20 +3182,29 @@ sub _populate_bugs_fulltext {
return if !@$bug_ids; return if !@$bug_ids;
my $num_bugs = scalar @$bug_ids; my $num_bugs = scalar @$bug_ids;
my $command = "INSERT";
my $where = ""; my $where = "";
if ($fulltext) { if ($fulltext) {
print "Updating bugs_fulltext for $num_bugs bugs...\n"; print "Updating bugs_fulltext for $num_bugs bugs...\n";
$where = "WHERE " . $dbh->sql_in('bugs.bug_id', $bug_ids); $where = "WHERE " . $dbh->sql_in('bugs.bug_id', $bug_ids);
# It turns out that doing a REPLACE INTO is up to 10x faster
# than any other possible method of updating the table, in MySQL,
# which matters a LOT for large installations.
if ($dbh->isa('Bugzilla::DB::Mysql')) {
$command = "REPLACE";
}
else {
$dbh->do("DELETE FROM bugs_fulltext WHERE " $dbh->do("DELETE FROM bugs_fulltext WHERE "
. $dbh->sql_in('bug_id', $bug_ids)); . $dbh->sql_in('bug_id', $bug_ids));
} }
}
else { else {
print "Populating bugs_fulltext with $num_bugs entries..."; print "Populating bugs_fulltext with $num_bugs entries...";
print " (this can take a long time.)\n"; print " (this can take a long time.)\n";
} }
my $newline = $dbh->quote("\n"); my $newline = $dbh->quote("\n");
$dbh->do( $dbh->do(
q{INSERT INTO bugs_fulltext (bug_id, short_desc, comments, qq{$command INTO bugs_fulltext (bug_id, short_desc, comments,
comments_noprivate) comments_noprivate)
SELECT bugs.bug_id, bugs.short_desc, } SELECT bugs.bug_id, bugs.short_desc, }
. $dbh->sql_group_concat('longdescs.thetext', $newline, 0) . $dbh->sql_group_concat('longdescs.thetext', $newline, 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment