Files
erpnext/erpnext/tests/test_perf.py
mergify[bot] 3879cbd86d fix: improved indexing for SLE queries. (backport #47194) (#47822)
* fix: improved indexing for SLE queries. (#47194)

(cherry picked from commit b49a835b4c)

# Conflicts:
#	erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json

* chore: fix conflicts

---------

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
2025-05-30 15:36:51 +05:30

24 lines
675 B
Python

import frappe
from frappe.tests.utils import FrappeTestCase
INDEXED_FIELDS = {
"Bin": ["item_code"],
"GL Entry": ["voucher_no", "posting_date", "company", "party"],
"Purchase Order Item": ["item_code"],
}
class TestPerformance(FrappeTestCase):
def test_ensure_indexes(self):
# These fields are not explicitly indexed BUT they are prefix in some
# other composite index. If those are removed this test should be
# updated accordingly.
for doctype, fields in INDEXED_FIELDS.items():
for field in fields:
self.assertTrue(
frappe.db.sql(
f"""SHOW INDEX FROM `tab{doctype}`
WHERE Column_name = "{field}" AND Seq_in_index = 1"""
)
)