summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2018-12-25 12:36:03 -0500
committerTim Graham <timograham@gmail.com>2018-12-26 09:20:21 -0500
commitec7bf6d826e6ce745f81a6f891430d32f37a7651 (patch)
treed7141ebb658593cd7ce54cd9d8dd383b2b774253
parent2b2ae4eeb75ea53613a0992f3927e65f89affcce (diff)
Refs #20483 -- Cached Oracle references retrieval on sql_flush().
-rw-r--r--django/db/backends/oracle/operations.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
index 40a1f730ce..11a271385f 100644
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -1,6 +1,7 @@
import datetime
import re
import uuid
+from functools import lru_cache
from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
@@ -315,7 +316,7 @@ END;
def return_insert_id(self):
return "RETURNING %s INTO %%s", (InsertIdVar(),)
- def _foreign_key_constraints(self, table_name, recursive=False):
+ def __foreign_key_constraints(self, table_name, recursive):
with self.connection.cursor() as cursor:
if recursive:
cursor.execute("""
@@ -348,6 +349,12 @@ END;
""", (table_name,))
return cursor.fetchall()
+ @cached_property
+ def _foreign_key_constraints(self):
+ # 512 is large enough to fit the ~330 tables (as of this writing) in
+ # Django's test suite.
+ return lru_cache(maxsize=512)(self.__foreign_key_constraints)
+
def sql_flush(self, style, tables, sequences, allow_cascade=False):
if tables:
truncated_tables = {table.upper() for table in tables}