Skip to content

Commit 39fecd2

Browse files
authored
Merge pull request #4835 from bjester/jit-setting
Conditionalize the JIT setting
2 parents bccbaa7 + 5045248 commit 39fecd2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
from django.db.backends.postgresql.features import DatabaseFeatures
12
from django.db.backends.signals import connection_created
23
from django.dispatch import receiver
34

45

56
@receiver(connection_created)
67
def set_jit(sender, connection, **kwargs):
78
"""
8-
Disable Just-In-Time compilation for PostgreSQL databases, at least until we can
9+
Disable Just-In-Time compilation for PostgreSQL databases >= 11, at least until we can
910
optimize its use.
1011
https://www.postgresql.org/docs/12/runtime-config-query.html#GUC-JIT
1112
"""
1213
if connection.vendor == 'postgresql':
13-
with connection.cursor() as cursor:
14-
cursor.execute("SET jit = 'off';")
14+
db_features = DatabaseFeatures(connection)
15+
# JIT is new in v11, and for reference this returns True for v11 and following
16+
if db_features.is_postgresql_11:
17+
with connection.cursor() as cursor:
18+
cursor.execute("SET jit = 'off';")

0 commit comments

Comments
 (0)