fix: dropping index to improve performance (#42820)

fix: droping index to improve peformance
This commit is contained in:
rohitwaghchaure
2024-08-19 16:58:25 +05:30
committed by GitHub
parent 1511280464
commit 5404b21c7d
3 changed files with 17 additions and 1 deletions

View File

@@ -375,3 +375,4 @@ erpnext.patches.v15_0.update_warehouse_field_in_asset_repair_consumed_item_docty
erpnext.patches.v15_0.update_asset_repair_field_in_stock_entry
erpnext.patches.v15_0.update_total_number_of_booked_depreciations
erpnext.patches.v15_0.do_not_use_batchwise_valuation
erpnext.patches.v15_0.drop_index_posting_datetime_from_sle

View File

@@ -0,0 +1,16 @@
import click
import frappe
def execute():
table = "tabStock Ledger Entry"
index = "posting_datetime_creation_index"
if not frappe.db.has_index(table, index):
return
try:
frappe.db.sql_ddl(f"ALTER TABLE `{table}` DROP INDEX `{index}`")
click.echo(f"✓ dropped {index} index from {table}")
except Exception:
frappe.log_error("Failed to drop index")

View File

@@ -351,4 +351,3 @@ def on_doctype_update():
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")
frappe.db.add_index("Stock Ledger Entry", ["posting_datetime", "creation"])