diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py index c101b772c02..07c6aa71d8e 100644 --- a/superset/models/sql_lab.py +++ b/superset/models/sql_lab.py @@ -17,6 +17,7 @@ """A collection of ORM sqlalchemy models for SQL Lab""" import re from datetime import datetime +from functools import lru_cache from typing import Any, Dict, List import simplejson as json @@ -204,6 +205,7 @@ class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin): return "/superset/sqllab?savedQueryId={0}".format(self.id) @property + @lru_cache(maxsize=2) def sql_tables(self) -> List[Table]: return list(ParsedQuery(self.sql).tables)