From c0dab55fcc42f5afe2b8ca7ad16464ea20c4bd12 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 19 Jun 2026 12:54:19 +0000 Subject: [PATCH] perf: composite index on (serial_no, warehouse, posting_datetime) for Serial and Batch Entry (backport #56032) (#56166) * perf: composite index on (serial_no, warehouse, posting_datetime) (cherry picked from commit b1b6ae98edfa45be4ba9cebf38a604aaa1982811) # Conflicts: # erpnext/patches.txt * chore: fix conflicts Removed conflicting patch entries and retained relevant ones. * chore: fix conflicts --------- Co-authored-by: Rohit Waghchaure --- erpnext/patches.txt | 1 + .../v16_0/drop_redundant_serial_no_index_from_sabb.py | 7 +++++++ .../serial_and_batch_entry/serial_and_batch_entry.json | 9 +++------ .../serial_and_batch_entry/serial_and_batch_entry.py | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 erpnext/patches/v16_0/drop_redundant_serial_no_index_from_sabb.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 4e3ba999eb9..4f129c918f0 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -483,3 +483,4 @@ erpnext.patches.v16_0.fix_titles erpnext.patches.v16_0.set_not_applicable_on_german_item_tax_templates erpnext.patches.v16_0.clear_procedures_from_receivable_report erpnext.patches.v16_0.migrate_address_contact_custom_fields +erpnext.patches.v16_0.drop_redundant_serial_no_index_from_sabb diff --git a/erpnext/patches/v16_0/drop_redundant_serial_no_index_from_sabb.py b/erpnext/patches/v16_0/drop_redundant_serial_no_index_from_sabb.py new file mode 100644 index 00000000000..8d376cda152 --- /dev/null +++ b/erpnext/patches/v16_0/drop_redundant_serial_no_index_from_sabb.py @@ -0,0 +1,7 @@ +from frappe.database.utils import drop_index_if_exists + + +def execute(): + drop_index_if_exists("tabSerial and Batch Entry", "serial_no") + drop_index_if_exists("tabSerial and Batch Entry", "warehouse") + drop_index_if_exists("tabSerial and Batch Entry", "type_of_transaction") diff --git a/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.json b/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.json index b5d0200c1c2..293a0412bae 100644 --- a/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.json +++ b/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.json @@ -37,8 +37,7 @@ "in_list_view": 1, "in_standard_filter": 1, "label": "Serial No", - "options": "Serial No", - "search_index": 1 + "options": "Serial No" }, { "depends_on": "eval:parent.has_batch_no == 1", @@ -62,8 +61,7 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Warehouse", - "options": "Warehouse", - "search_index": 1 + "options": "Warehouse" }, { "fieldname": "column_break_2", @@ -178,8 +176,7 @@ "fieldtype": "Data", "label": "Type of Transaction", "no_copy": 1, - "read_only": 1, - "search_index": 1 + "read_only": 1 }, { "fieldname": "column_break_eykr", diff --git a/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.py b/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.py index adeb6a388da..c217efd5d04 100644 --- a/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.py +++ b/erpnext/stock/doctype/serial_and_batch_entry/serial_and_batch_entry.py @@ -42,3 +42,4 @@ class SerialandBatchEntry(Document): def on_doctype_update(): frappe.db.add_index("Serial and Batch Entry", ["warehouse", "batch_no", "posting_datetime"]) + frappe.db.add_index("Serial and Batch Entry", ["warehouse", "serial_no", "posting_datetime"])