feat: add size async caching (#2532)

This commit is contained in:
cthomas
2025-05-29 16:45:29 -07:00
committed by GitHub
parent 0020183459
commit 75d1b50f5d
2 changed files with 6 additions and 2 deletions

View File

@@ -90,4 +90,8 @@ class AgentPassage(BasePassage, AgentMixin):
Index("agent_passages_created_at_id_idx", "created_at", "id"),
{"extend_existing": True},
)
return (Index("agent_passages_created_at_id_idx", "created_at", "id"), {"extend_existing": True})
return (
Index("ix_agent_passages_org_agent", "organization_id", "agent_id"),
Index("agent_passages_created_at_id_idx", "created_at", "id"),
{"extend_existing": True},
)

View File

@@ -840,7 +840,7 @@ class SqlalchemyBase(CommonSqlalchemyMetaMixins, Base):
**kwargs,
):
logger.debug(f"Calculating size for {cls.__name__} with filters {kwargs}")
query = select(func.count()).select_from(cls)
query = select(func.count(1)).select_from(cls)
if actor:
query = cls.apply_access_predicate(query, actor, access, access_type)