feat: add partial indexes on conversations for app_id with created_at and updated_at (#32616)

This commit is contained in:
Novice
2026-03-05 16:53:28 +08:00
committed by GitHub
parent ebda5efe27
commit c913a629df
2 changed files with 49 additions and 0 deletions

View File

@ -711,6 +711,18 @@ class Conversation(Base):
__table_args__ = (
sa.PrimaryKeyConstraint("id", name="conversation_pkey"),
sa.Index("conversation_app_from_user_idx", "app_id", "from_source", "from_end_user_id"),
sa.Index(
"conversation_app_created_at_idx",
"app_id",
sa.text("created_at DESC"),
postgresql_where=sa.text("is_deleted IS false"),
),
sa.Index(
"conversation_app_updated_at_idx",
"app_id",
sa.text("updated_at DESC"),
postgresql_where=sa.text("is_deleted IS false"),
),
)
id: Mapped[str] = mapped_column(StringUUID, default=lambda: str(uuid4()))