refactor: adjust database indexes by adding high-frequency composite indexes and removing redundant id indexes

This commit is contained in:
jxxghp
2026-05-09 20:04:05 +08:00
parent ac11b303b3
commit cd5e693302
12 changed files with 346 additions and 25 deletions
+5 -1
View File
@@ -1,6 +1,6 @@
from typing import Optional
from sqlalchemy import Column, Integer, String, Float, JSON, select
from sqlalchemy import Column, Integer, String, Float, JSON, Index, select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Session
@@ -73,6 +73,10 @@ class SubscribeHistory(Base):
# 剧集组
episode_group = Column(String)
__table_args__ = (
Index('ix_subscribehistory_type_date', 'type', 'date'),
)
@classmethod
@db_query
def list_by_type(cls, db: Session, mtype: str, page: Optional[int] = 1, count: Optional[int] = 30):