From 228e011819959ae34287a91c144fbedb3c350d07 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 15 Dec 2021 19:18:41 +0530 Subject: [PATCH] perf: remove forcing of posting sort index on stock balance (#28902) mysql is generally smart enough to figure out which index is better based on cardinality of index. While posting sort index is better for low item high # of SLE scenario it's bad for high item variety each with lower count of SLEs. --- erpnext/stock/report/stock_balance/stock_balance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index c0b89fdd09..3c7b26bb1b 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -167,7 +167,7 @@ def get_stock_ledger_entries(filters, items): sle.company, sle.voucher_type, sle.qty_after_transaction, sle.stock_value_difference, sle.item_code as name, sle.voucher_no, sle.stock_value, sle.batch_no from - `tabStock Ledger Entry` sle force index (posting_sort_index) + `tabStock Ledger Entry` sle where sle.docstatus < 2 %s %s and is_cancelled = 0 order by sle.posting_date, sle.posting_time, sle.creation, sle.actual_qty""" % #nosec