From 74fef0bf0c790851c2dd72e6d08561a90b711de4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Mon, 7 Jan 2013 21:13:30 +0100 Subject: [PATCH] Bug 824361: Add an index on (bug_id, work_time) in the longdescs table to improve performance r=dkl a=LpSolit --- Bugzilla/DB/Schema.pm | 2 +- Bugzilla/Install/DB.pm | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index d167f8a4fe..f9784ff439 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -398,7 +398,7 @@ use constant ABSTRACT_SCHEMA => { extra_data => {TYPE => 'varchar(255)'} ], INDEXES => [ - longdescs_bug_id_idx => ['bug_id'], + longdescs_bug_id_idx => [qw(bug_id work_time)], longdescs_who_idx => [qw(who bug_id)], longdescs_bug_when_idx => ['bug_when'], ], diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index a6f0884828..ffcafeb4f8 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -700,6 +700,9 @@ sub update_table_definitions { # 2012-08-01 koosha.khajeh@gmail.com - Bug 187753 _shorten_long_quips(); + # 2012-12-23 LpSolit@gmail.com - Bug 824361 + _fix_longdescs_indexes(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -3729,6 +3732,15 @@ sub _fix_longdescs_primary_key { } } +sub _fix_longdescs_indexes { + my $dbh = Bugzilla->dbh; + my $bug_id_idx = $dbh->bz_index_info('longdescs', 'longdescs_bug_id_idx'); + if ($bug_id_idx && scalar @{$bug_id_idx->{'FIELDS'}} < 2) { + $dbh->bz_drop_index('longdescs', 'longdescs_bug_id_idx'); + $dbh->bz_add_index('longdescs', 'longdescs_bug_id_idx', [qw(bug_id work_time)]); + } +} + sub _fix_dependencies_dupes { my $dbh = Bugzilla->dbh; my $blocked_idx = $dbh->bz_index_info('dependencies', 'dependencies_blocked_idx'); -- 2.47.2