From e8cca83b5284aa00287edfb75868da4f3f47b738 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Fri, 18 Oct 2013 13:35:02 +0800 Subject: Bug 926109: fix 'too many joins' fix --- Bugzilla/Search.pm | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'Bugzilla/Search.pm') diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 7787104ba..d66a6398f 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -744,6 +744,23 @@ sub data { last; } + # BMO - to avoid massive amounts of joins, if we're selecting a lot of + # tracking flags, replace them with placeholders. the values will be + # retrieved later and injected into the result. + my %tf_map = map { $_ => 1 } Bugzilla::Extension::TrackingFlags::Flag->get_all_names(); + my @tf_selected = grep { exists $tf_map{$_} } @orig_fields; + # mysql has a limit of 61 joins, and we want to avoid massive amounts of joins + # 30 ensures we won't hit the limit, nor generate too many joins + if (scalar @tf_selected > 30) { + foreach my $column (@tf_selected) { + $self->COLUMNS->{$column}->{name} = "'---'"; + } + $self->{tracking_flags} = \@tf_selected; + } + else { + $self->{tracking_flags} = []; + } + my $start_time = [gettimeofday()]; my $sql = $self->_sql; # Do we just want bug IDs to pass to the 2nd query or all the data immediately? @@ -991,23 +1008,6 @@ sub _display_columns { # expects to get them back in the exact same order. my @columns = $self->_input_columns; - # BMO - to avoid massive amounts of joins, if we're selecting a lot of - # tracking flags, replace them with placeholders. the values will be - # retrieved later and injected into the result. - my %tf_map = map { $_ => 1 } Bugzilla::Extension::TrackingFlags::Flag->get_all_names(); - my @tf_selected = grep { exists $tf_map{$_} } @columns; - # mysql has a limit of 61 joins, and we want to avoid massive amounts of joins - # 30 ensures we won't hit the limit, nor generate too many joins - if (scalar @tf_selected > 30) { - foreach my $column (@tf_selected) { - $self->COLUMNS->{$column}->{name} = "'---'"; - } - $self->{tracking_flags} = \@tf_selected; - } - else { - $self->{tracking_flags} = []; - } - # Only add columns which are not already listed. my %list = map { $_ => 1 } @columns; foreach my $column ($self->_extra_columns) { -- cgit v1.2.3-24-g4f1b