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
+7 -3
View File
@@ -1,4 +1,4 @@
from sqlalchemy import Column, String, JSON, select
from sqlalchemy import Column, String, JSON, Index, select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Session
@@ -16,10 +16,14 @@ class PluginData(Base):
插件数据表
"""
id = get_id_column()
plugin_id = Column(String, nullable=False, index=True)
key = Column(String, index=True, nullable=False)
plugin_id = Column(String, nullable=False)
key = Column(String, nullable=False)
value = Column(JSON)
__table_args__ = (
Index('ix_plugindata_plugin_id_key', 'plugin_id', 'key'),
)
@classmethod
@db_query
def get_plugin_data(cls, db: Session, plugin_id: str):