From 10422dc37bb3ce7494fe42f8d932c21e546df520 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 20 Sep 2026 19:09:55 +1000 Subject: [PATCH] [db] Disable JIT for postgres (#12893) * disable postgres JIT by default * Update docs --- docs/docs/start/config.md | 4 ++++ .../InvenTree/InvenTree/setting/db_backend.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/docs/start/config.md b/docs/docs/start/config.md index fd40a4bde9..f71cb3cd1d 100644 --- a/docs/docs/start/config.md +++ b/docs/docs/start/config.md @@ -280,6 +280,10 @@ If running with a PostgreSQL database backend, the following additional options | `INVENTREE_DB_TCP_KEEPALIVES_COUNT` | database.tcp_keepalives_count | 5 | TCP keepalive count | | `INVENTREE_DB_TCP_USER_TIMEOUT` | database.tcp_user_timeout | 2000 | TCP user timeout (ms) | | `INVENTREE_DB_ISOLATION_SERIALIZABLE` | database.serializable | False | Database isolation level configured to "serializable" | +| `INVENTREE_DB_JIT_ENABLED` | database.jit_enabled | False | Enable JIT compilation for PostgreSQL queries | + +!!! info "JIT Compilation" + PostgreSQL supports [JIT compilation](https://www.postgresql.org/docs/current/jit.html) for queries. This is disabled by default, as it can cause performance issues for small queries. ### MySQL Settings diff --git a/src/backend/InvenTree/InvenTree/setting/db_backend.py b/src/backend/InvenTree/InvenTree/setting/db_backend.py index 6defd52374..7d169bd59e 100644 --- a/src/backend/InvenTree/InvenTree/setting/db_backend.py +++ b/src/backend/InvenTree/InvenTree/setting/db_backend.py @@ -208,6 +208,19 @@ def set_postgres_options(db_options: dict): 'inventree-worker' if isInWorkerThread() else 'inventree-server' ) + extra_options = [] + + if 'options' in db_options: + extra_options.append(db_options['options']) + + if not get_boolean_setting( + 'INVENTREE_DB_JIT_ENABLED', 'database.jit_enabled', False + ): + extra_options.append('-c jit=off') + + if extra_options: + db_options['options'] = ' '.join(extra_options) + def set_mysql_options(db_options: dict): """Set database options specific to mysql backend."""