From fb0e2baa5a4254930f2b5e950173991ddcd8afc9 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Sat, 15 Mar 2025 13:47:45 +0530 Subject: [PATCH] perf: store `touched_tables` in local var --- frappe/database/database.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frappe/database/database.py b/frappe/database/database.py index 888ce8d2d0..d965dda5b8 100644 --- a/frappe/database/database.py +++ b/frappe/database/database.py @@ -1424,9 +1424,13 @@ class Database: for regex in (SINGLE_WORD_PATTERN, MULTI_WORD_PATTERN): tables += [groups[1] for groups in regex.findall(query)] - if frappe.flags.touched_tables is None: - frappe.flags.touched_tables = set() - frappe.flags.touched_tables.update(tables) + touched_tables = frappe.local.flags.touched_tables + + if touched_tables is None: + touched_tables = set() + frappe.local.flags.touched_tables = touched_tables + + touched_tables.update(tables) def bulk_insert( self,