diff --git a/backend/common/core/config.py b/backend/common/core/config.py index de7fc7bb..043de6cc 100644 --- a/backend/common/core/config.py +++ b/backend/common/core/config.py @@ -92,5 +92,10 @@ class Settings(BaseSettings): EMBEDDING_SIMILARITY: float = 0.4 EMBEDDING_TOP_COUNT: int = 5 + PG_POOL_SIZE: int = 20 + PG_MAX_OVERFLOW: int = 30 + PG_POOL_RECYCLE: int = 3600 + PG_POOL_PRE_PING: bool = True + settings = Settings() # type: ignore diff --git a/backend/common/core/db.py b/backend/common/core/db.py index dd6c9781..d4adf346 100644 --- a/backend/common/core/db.py +++ b/backend/common/core/db.py @@ -2,8 +2,11 @@ from sqlmodel import Session, create_engine, SQLModel from common.core.config import settings -engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI), pool_size=20, max_overflow=30, pool_recycle=3600, - pool_pre_ping=True) +engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI), + pool_size=settings.PG_POOL_SIZE, + max_overflow=settings.PG_MAX_OVERFLOW, + pool_recycle=settings.PG_POOL_RECYCLE, + pool_pre_ping=settings.PG_POOL_PRE_PING) def get_session():