mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-21 03:04:34 +00:00
voucher_detail_no is supposed to have an index, it was added on
on_doctype_update function of table, however this function is only
called if DocType itself is updated and `on_update` is called on
DocType. Stock ledger Entry doctype hasn't changed since addition of
this index in function.
Before: Lack of this index was causing full table scan in
get_future_sle_to_fix function. (~50 seconds in a reposting job)
After: Single row is fetched (~0.5 second in full reposting job)
Learnings:
1. Add simple indexes via doctype only
2. For complex indexes always change doctype.json file for it to take
effect.
(cherry picked from commit 6019f60d0a)
Co-authored-by: Ankush Menat <ankush@iwebnotes.com>