refactor: Increase database connection pool

This commit is contained in:
junjun
2025-09-10 12:20:36 +08:00
parent 5b32418292
commit 1976d79796
2 changed files with 10 additions and 2 deletions
+5
View File
@@ -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
+5 -2
View File
@@ -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():