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
+6 -2
View File
@@ -1,7 +1,7 @@
import time
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
@@ -64,7 +64,7 @@ class Subscribe(Base):
# 创建时间
date = Column(String)
# 订阅用户
username = Column(String)
username = Column(String, index=True)
# 订阅站点
sites = Column(JSON, default=list)
# 下载器
@@ -88,6 +88,10 @@ class Subscribe(Base):
# 选择的剧集组
episode_group = Column(String)
__table_args__ = (
Index('ix_subscribe_type_date', 'type', 'date'),
)
@classmethod
@db_query
def exists(cls, db: Session, tmdbid: Optional[int] = None, doubanid: Optional[str] = None,