mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor: adjust database indexes by adding high-frequency composite indexes and removing redundant id indexes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import Column, Integer, String, JSON
|
||||
from sqlalchemy import Column, Integer, String, JSON, Index
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -29,7 +29,7 @@ class MediaServerItem(Base):
|
||||
# 年份
|
||||
year = Column(String)
|
||||
# TMDBID
|
||||
tmdbid = Column(Integer, index=True)
|
||||
tmdbid = Column(Integer)
|
||||
# IMDBID
|
||||
imdbid = Column(String, index=True)
|
||||
# TVDBID
|
||||
@@ -43,6 +43,10 @@ class MediaServerItem(Base):
|
||||
# 同步时间
|
||||
lst_mod_date = Column(String, default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||
|
||||
__table_args__ = (
|
||||
Index('ix_mediaserveritem_tmdbid_item_type', 'tmdbid', 'item_type'),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@db_query
|
||||
def get_by_itemid(cls, db: Session, item_id: str):
|
||||
|
||||
Reference in New Issue
Block a user