perf: new column posting datetime in SLE to optimize stock ledger related queries

(cherry picked from commit d80ca523a4)
This commit is contained in:
Rohit Waghchaure
2024-02-07 21:56:21 +05:30
parent 785131121d
commit 5e68ebd030
19 changed files with 2218 additions and 124 deletions

View File

@@ -0,0 +1,19 @@
import frappe
def execute():
frappe.db.sql(
"""
UPDATE `tabStock Ledger Entry`
SET posting_datetime = timestamp(posting_date, posting_time)
"""
)
drop_indexes()
def drop_indexes():
if not frappe.db.has_index("tabStock Ledger Entry", "posting_sort_index"):
return
frappe.db.sql_ddl("ALTER TABLE `tabStock Ledger Entry` DROP INDEX `posting_sort_index`")