Skip to content

Commit

Permalink
perf: Drop name part from posting sort index (#33551)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8a56df6)

# Conflicts:
#	erpnext/patches.txt
  • Loading branch information
ankush authored and mergify[bot] committed Jan 10, 2023
1 parent 914e2fd commit f501575
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ erpnext.patches.v14_0.fix_crm_no_of_employees
erpnext.patches.v14_0.create_accounting_dimensions_in_subcontracting_doctypes
erpnext.patches.v14_0.fix_subcontracting_receipt_gl_entries
erpnext.patches.v14_0.migrate_remarks_from_gl_to_payment_ledger
<<<<<<< HEAD
=======
erpnext.patches.v13_0.update_schedule_type_in_loans
erpnext.patches.v13_0.drop_unused_sle_index_parts
>>>>>>> 8a56df695d (perf: Drop `name` part from posting sort index (#33551))
erpnext.patches.v14_0.create_accounting_dimensions_for_asset_capitalization
erpnext.patches.v13_0.update_schedule_type_in_loans
erpnext.patches.v14_0.update_partial_tds_fields
Expand Down
14 changes: 14 additions & 0 deletions erpnext/patches/v13_0/drop_unused_sle_index_parts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import frappe

from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import on_doctype_update


def execute():
try:
frappe.db.sql_ddl("ALTER TABLE `tabStock Ledger Entry` DROP INDEX `posting_sort_index`")
except Exception:
frappe.log_error("Failed to drop index")
return

# Recreate indexes
on_doctype_update()
11 changes: 3 additions & 8 deletions erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,9 @@ def on_cancel(self):


def on_doctype_update():
if not frappe.db.has_index("tabStock Ledger Entry", "posting_sort_index"):
frappe.db.commit()
frappe.db.add_index(
"Stock Ledger Entry",
fields=["posting_date", "posting_time", "name"],
index_name="posting_sort_index",
)

frappe.db.add_index(
"Stock Ledger Entry", fields=["posting_date", "posting_time"], index_name="posting_sort_index"
)
frappe.db.add_index("Stock Ledger Entry", ["voucher_no", "voucher_type"])
frappe.db.add_index("Stock Ledger Entry", ["batch_no", "item_code", "warehouse"])
frappe.db.add_index("Stock Ledger Entry", ["warehouse", "item_code"], "item_warehouse")

0 comments on commit f501575

Please sign in to comment.