perf: use LEFT JOIN instead of NOT EXISTS
This commit is contained in:
parent
e36c8ce5be
commit
58d867503b
@ -157,12 +157,19 @@ def get_next_higher_level_boms(
|
|||||||
def get_leaf_boms() -> List[str]:
|
def get_leaf_boms() -> List[str]:
|
||||||
"Get BOMs that have no dependencies."
|
"Get BOMs that have no dependencies."
|
||||||
|
|
||||||
return frappe.db.sql_list(
|
bom = frappe.qb.DocType("BOM")
|
||||||
"""select name from `tabBOM` bom
|
bom_item = frappe.qb.DocType("BOM Item")
|
||||||
where docstatus=1 and is_active=1
|
|
||||||
and not exists(select bom_no from `tabBOM Item`
|
boms = (
|
||||||
where parent=bom.name and bom_no !='')"""
|
frappe.qb.from_(bom)
|
||||||
)
|
.left_join(bom_item)
|
||||||
|
.on((bom.name == bom_item.parent) & (bom_item.bom_no != ""))
|
||||||
|
.select(bom.name)
|
||||||
|
.where((bom.docstatus == 1) & (bom.is_active == 1) & (bom_item.bom_no.isnull()))
|
||||||
|
.distinct()
|
||||||
|
).run(pluck=True)
|
||||||
|
|
||||||
|
return boms
|
||||||
|
|
||||||
|
|
||||||
def _generate_dependence_map() -> defaultdict:
|
def _generate_dependence_map() -> defaultdict:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user