From f62a30c0170f1837ce8be641aa27d4a795cb6a90 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:16:21 +0000 Subject: [PATCH] perf: Faster "show title in link field" on list view (#25597) (#25622) Ideally, this query should be converted to "Top N" variant and just pick first 20 records, join only them with other table and send data back. Currently we always group by `name` in list view. This makes "show title in link field" join queries insanely slow as it first queries entire table and then applies limit. (cherry picked from commit bad3b9e6e70ea7c423c205545bf3ec4c41638ffe) Co-authored-by: Ankush Menat --- frappe/public/js/frappe/list/base_list.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index 1befd08be2f..ea4365f6b98 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -448,15 +448,22 @@ frappe.views.BaseList = class BaseList { } get_args() { + let filters = this.get_filters_for_args(); + let group_by = this.get_group_by(); + let group_by_required = + Array.isArray(filters) && + filters.some((filter) => { + return filter[0] !== this.doctype; + }); return { doctype: this.doctype, fields: this.get_fields(), - filters: this.get_filters_for_args(), + filters, order_by: this.sort_selector && this.sort_selector.get_sql_string(), start: this.start, page_length: this.page_length, view: this.view, - group_by: this.get_group_by(), + group_by: group_by_required ? group_by : null, }; }