seitime-frappe/frappe/patches/v15_0/drop_modified_index.py
Ankush Menat 82cd238f54
perf!: Only add modified index on parent doctypes (#18119)
When are child tables sorted by timestamp by default?
2022-09-15 19:16:12 +05:30

21 lines
440 B
Python

import frappe
from frappe.patches.v14_0.drop_unused_indexes import drop_index_if_exists
def execute():
if frappe.db.db_type == "postgres":
return
db_tables = frappe.db.get_tables(cached=False)
child_tables = frappe.get_all(
"DocType",
{"istable": 1, "is_virtual": 0},
pluck="name",
)
for doctype in child_tables:
table = f"tab{doctype}"
if table not in db_tables:
continue
drop_index_if_exists(table, "modified")