diff options
author | Sean McGivern <sean@gitlab.com> | 2018-10-17 13:56:52 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-10-17 14:14:48 +0100 |
commit | 2563352dcbf3de7650614ae939fe1467d3ff5945 (patch) | |
tree | 0a16eee2f3f4ac02b841bb1895425877eb930cbe | |
parent | e36f824ae991a6765026ac8df04b79abbd5f70ad (diff) | |
download | gitlab-ce-52271-remove-feature-flag-for-use_cte_for_group_issues_search.tar.gz |
Revert "Force Postgres to avoid trigram indexes when in a group"52271-remove-feature-flag-for-use_cte_for_group_issues_search
This reverts commit c03386c3914feca56802e6f99bbd0fd08d269472.
-rw-r--r-- | app/controllers/concerns/issuable_collections.rb | 1 | ||||
-rw-r--r-- | app/finders/issuable_finder.rb | 36 |
2 files changed, 5 insertions, 32 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index 5217b4be928..4f652ce7fbe 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -101,7 +101,6 @@ module IssuableCollections elsif @group @filter_params[:group_id] = @group.id @filter_params[:include_subgroups] = true - @filter_params[:use_cte_for_search] = true end @filter_params.permit(finder_type.valid_params) diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 17e9b59b355..899e6524964 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -25,7 +25,6 @@ # created_before: datetime # updated_after: datetime # updated_before: datetime -# use_cte_for_search: boolean # class IssuableFinder prepend FinderWithCrossProjectAccess @@ -57,7 +56,6 @@ class IssuableFinder sort state include_subgroups - use_cte_for_search ] end @@ -78,21 +76,19 @@ class IssuableFinder items = init_collection items = filter_items(items) - # This has to be last as we may use a CTE as an optimization fence by - # passing the use_cte_for_search param - # https://www.postgresql.org/docs/current/static/queries-with.html - items = by_search(items) + # Filtering by project HAS TO be the last because we use the project IDs yielded by the issuable query thus far + items = by_project(items) sort(items) end def filter_items(items) - items = by_project(items) items = by_scope(items) items = by_created_at(items) items = by_updated_at(items) items = by_state(items) items = by_group(items) + items = by_search(items) items = by_assignee(items) items = by_author(items) items = by_non_archived(items) @@ -114,6 +110,7 @@ class IssuableFinder # rubocop: disable CodeReuse/ActiveRecord def count_by_state count_params = params.merge(state: nil, sort: nil) + labels_count = label_names.any? ? label_names.count : 1 finder = self.class.new(current_user, count_params) counts = Hash.new(0) @@ -122,11 +119,6 @@ class IssuableFinder # per issuable, so we have to count those in Ruby - which is bad, but still # better than performing multiple queries. # - # This does not apply when we are using a CTE for the search, as the labels - # GROUP BY is inside the subquery in that case, so we set labels_count to 1. - labels_count = label_names.any? ? label_names.count : 1 - labels_count = 1 if use_cte_for_search? - finder.execute.reorder(nil).group(:state).count.each do |key, value| counts[count_key(key)] += value / labels_count end @@ -360,27 +352,9 @@ class IssuableFinder end # rubocop: enable CodeReuse/ActiveRecord - def use_cte_for_search? - return false unless search - return false unless Gitlab::Database.postgresql? - - params[:use_cte_for_search] - end - - # rubocop: disable CodeReuse/ActiveRecord def by_search(items) - return items unless search - - if use_cte_for_search? - cte = Gitlab::SQL::RecursiveCTE.new(klass.table_name) - cte << items - - items = klass.with(cte.to_arel).from(klass.table_name) - end - - items.full_search(search) + search ? items.full_search(search) : items end - # rubocop: enable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord def by_iids(items) |