perf: Drop name part from posting sort index (#33551)

This commit is contained in:
Ankush Menat 2023-01-10 09:54:15 +05:30 committed by GitHub
parent 59628f1934
commit 8a56df695d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 8 deletions

View File

@ -316,6 +316,7 @@ 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
erpnext.patches.v13_0.update_schedule_type_in_loans
erpnext.patches.v13_0.drop_unused_sle_index_parts
erpnext.patches.v14_0.create_accounting_dimensions_for_asset_capitalization
erpnext.patches.v14_0.update_partial_tds_fields
erpnext.patches.v14_0.create_incoterms_and_migrate_shipment

View File

@ -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()

View File

@ -221,14 +221,9 @@ class StockLedgerEntry(Document):
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")