Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
a9fd0d7e
Commit
a9fd0d7e
authored
Aug 13, 2008
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 442882: Populating bugs_fulltext can be very slow on large installations
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
parent
09a46476
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
19 deletions
+59
-19
Mysql.pm
Bugzilla/DB/Mysql.pm
+9
-0
DB.pm
Bugzilla/Install/DB.pm
+50
-19
No files found.
Bugzilla/DB/Mysql.pm
View file @
a9fd0d7e
...
...
@@ -106,6 +106,15 @@ sub bz_last_key {
return
$last_insert_id
;
}
sub
sql_group_concat
{
my
(
$self
,
$column
,
$separator
)
=
@_
;
my
$sep_sql
;
if
(
$separator
)
{
$sep_sql
=
" SEPARATOR $separator"
;
}
return
"GROUP_CONCAT($column$sep_sql)"
;
}
sub
sql_regexp
{
my
(
$self
,
$expr
,
$pattern
,
$nocheck
)
=
@_
;
...
...
Bugzilla/Install/DB.pm
View file @
a9fd0d7e
...
...
@@ -3029,26 +3029,57 @@ sub _populate_bugs_fulltext {
my
$bug_ids
=
$dbh
->
selectcol_arrayref
(
'SELECT bug_id FROM bugs'
);
return
if
!
@$bug_ids
;
print
"Populating bugs_fulltext.short_desc...\n"
;
$dbh
->
do
(
'INSERT INTO bugs_fulltext (bug_id, short_desc)
SELECT bug_id, short_desc FROM bugs'
);
print
"Populating bugs_fulltext comments fields...\n"
;
my
$count
=
1
;
my
$sth_all
=
$dbh
->
prepare
(
'SELECT thetext FROM longdescs
WHERE bug_id = ?'
);
my
$sth_nopriv
=
$dbh
->
prepare
(
'SELECT thetext FROM longdescs
WHERE bug_id = ? AND isprivate = 0'
);
my
$sth_update
=
$dbh
->
prepare
(
'UPDATE bugs_fulltext SET comments = ?, comments_noprivate = ?
WHERE bug_id = ?'
);
foreach
my
$id
(
@$bug_ids
)
{
my
$all
=
$dbh
->
selectcol_arrayref
(
$sth_all
,
undef
,
$id
);
my
$nopriv
=
$dbh
->
selectcol_arrayref
(
$sth_nopriv
,
undef
,
$id
);
$sth_update
->
execute
(
join
(
"\n"
,
@$all
),
join
(
"\n"
,
@$nopriv
),
$id
);
indicate_progress
({
total
=>
scalar
@$bug_ids
,
every
=>
100
,
current
=>
$count
++
});
# Populating bugs_fulltext can be very slow for large installs,
# so we special-case any DB that supports GROUP_CONCAT, which is
# a much faster way to do things.
if
(
UNIVERSAL::
can
(
$dbh
,
'sql_group_concat'
))
{
print
"Populating bugs_fulltext..."
;
print
" (this can take a long time.)\n"
;
# XXX This hack should probably be moved elsewhere.
if
(
$dbh
->
isa
(
'Bugzilla::DB::Mysql'
))
{
$dbh
->
do
(
'SET SESSION group_concat_max_len = 128000000'
);
$dbh
->
do
(
'SET SESSION max_allowed_packet = 128000000'
);
}
$dbh
->
do
(
q{INSERT INTO bugs_fulltext (bug_id, short_desc, comments,
comments_noprivate)
SELECT bugs.bug_id, bugs.short_desc, }
.
$dbh
->
sql_group_concat
(
'longdescs.thetext'
,
'\'\n\''
)
.
', '
.
$dbh
->
sql_group_concat
(
'nopriv.thetext'
,
'\'\n\''
)
.
q{ FROM bugs
LEFT JOIN longdescs
ON bugs.bug_id = longdescs.bug_id
LEFT JOIN longdescs AS nopriv
ON longdescs.comment_id = nopriv.comment_id
AND nopriv.isprivate = 0 }
.
$dbh
->
sql_group_by
(
'bugs.bug_id'
,
'bugs.short_desc'
));
}
# The slow way, without group_concat.
else
{
print
"Populating bugs_fulltext.short_desc...\n"
;
$dbh
->
do
(
'INSERT INTO bugs_fulltext (bug_id, short_desc)
SELECT bug_id, short_desc FROM bugs'
);
my
$count
=
1
;
my
$sth_all
=
$dbh
->
prepare
(
'SELECT thetext FROM longdescs
WHERE bug_id = ?'
);
my
$sth_nopriv
=
$dbh
->
prepare
(
'SELECT thetext FROM longdescs
WHERE bug_id = ? AND isprivate = 0'
);
my
$sth_update
=
$dbh
->
prepare
(
'UPDATE bugs_fulltext SET comments = ?, comments_noprivate = ?
WHERE bug_id = ?'
);
print
"Populating bugs_fulltext comment fields...\n"
;
foreach
my
$id
(
@$bug_ids
)
{
my
$all
=
$dbh
->
selectcol_arrayref
(
$sth_all
,
undef
,
$id
);
my
$nopriv
=
$dbh
->
selectcol_arrayref
(
$sth_nopriv
,
undef
,
$id
);
$sth_update
->
execute
(
join
(
"\n"
,
@$all
),
join
(
"\n"
,
@$nopriv
),
$id
);
indicate_progress
({
total
=>
scalar
@$bug_ids
,
every
=>
100
,
current
=>
$count
++
});
}
print
"\n"
;
}
print
"\n"
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment