fix: renamed PostGreSQL options env variable and allowed LRU cache to be an optional env variable

This commit is contained in:
kevinnkansah 2025-10-06 11:56:09 +02:00
parent d8a9617c0e
commit 22a7b482c5
2 changed files with 16 additions and 4 deletions

View file

@ -310,10 +310,13 @@ POSTGRES_IVFFLAT_LISTS=100
# POSTGRES_SSL_ROOT_CERT=/path/to/ca-cert.pem # POSTGRES_SSL_ROOT_CERT=/path/to/ca-cert.pem
# POSTGRES_SSL_CRL=/path/to/crl.pem # POSTGRES_SSL_CRL=/path/to/crl.pem
### PostgreSQL Server Options (for Supabase Supavisor) ### PostgreSQL Server Settings (for Supabase Supavisor)
# Use this to pass extra options to the PostgreSQL connection string. # Use this to pass extra options to the PostgreSQL connection string.
# For Supabase, you might need to set it like this: # For Supabase, you might need to set it like this:
# POSTGRES_SERVER_OPTIONS="options=reference%3D[project-ref]" # POSTGRES_SERVER_SETTINGS="options=reference%3D[project-ref]"
# Default is 100 set to 0 to disable
# POSTGRES_STATEMENT_CACHE_SIZE=100
### Neo4j Configuration ### Neo4j Configuration
NEO4J_URI=neo4j+s://xxxxxxxx.databases.neo4j.io NEO4J_URI=neo4j+s://xxxxxxxx.databases.neo4j.io

View file

@ -76,6 +76,7 @@ class PostgreSQLDB:
# Server settings # Server settings
self.server_settings = config.get("server_settings") self.server_settings = config.get("server_settings")
self.statement_cache_size = int(config.get("statement_cache_size"))
if self.user is None or self.password is None or self.database is None: if self.user is None or self.password is None or self.database is None:
raise ValueError("Missing database user, password, or database") raise ValueError("Missing database user, password, or database")
@ -161,9 +162,13 @@ class PostgreSQLDB:
"port": self.port, "port": self.port,
"min_size": 1, "min_size": 1,
"max_size": self.max, "max_size": self.max,
"statement_cache_size": 0, "statement_cache_size": self.statement_cache_size,
} }
logger.info(
f"PostgreSQL, statement LRU cache size set as: {self.statement_cache_size}"
)
# Add SSL configuration if provided # Add SSL configuration if provided
ssl_context = self._create_ssl_context() ssl_context = self._create_ssl_context()
if ssl_context is not None: if ssl_context is not None:
@ -1392,9 +1397,13 @@ class ClientManager:
), ),
# Server settings for Supabase # Server settings for Supabase
"server_settings": os.environ.get( "server_settings": os.environ.get(
"POSTGRES_SERVER_OPTIONS", "POSTGRES_SERVER_SETTINGS",
config.get("postgres", "server_options", fallback=None), config.get("postgres", "server_options", fallback=None),
), ),
"statement_cache_size": os.environ.get(
"POSTGRES_STATEMENT_CACHE_SIZE",
config.get("postgres", "statement_cache_size", fallback=None),
),
} }
@classmethod @classmethod