Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionalize the JIT setting #4835

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions contentcuration/contentcuration/signals.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from django.db.backends.postgresql.features import DatabaseFeatures
from django.db.backends.signals import connection_created
from django.dispatch import receiver


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