From 5c14f2c256660bf8f15db09d876b098ff859a53c Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 6 Feb 2019 21:04:20 +0530 Subject: [PATCH] remove distinct from count We shouldn't do a distinct count on primary key, as it is not required, and is also slow. See below query run times. MariaDB [c6b2c772b91fd3d8]> select count(distinct name) from `tabStock Ledger Entry`; +----------------------+ | count(distinct name) | +----------------------+ | 3268372 | +----------------------+ 1 row in set (14.65 sec) MariaDB [c6b2c772b91fd3d8]> select count(name) from `tabStock Ledger Entry`; +-------------+ | count(name) | +-------------+ | 3268372 | +-------------+ 1 row in set (0.24 sec) --- frappe/public/js/frappe/list/list_view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 29bdbd1b92..7a34bb3cb5 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -597,7 +597,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { args: { doctype: this.doctype, filters: this.get_filters_for_args(), - fields: [`count(distinct ${frappe.model.get_full_column_name('name', this.doctype)}) as total_count`], + fields: [`count(${frappe.model.get_full_column_name('name', this.doctype)}) as total_count`], } }).then(r => { this.total_count = r.message.values[0][0] || current_count;