From dcd8a1094c761e2626da6341334ac1caaddeda3b Mon Sep 17 00:00:00 2001 From: ctrlkk <88469720+ctrlkk@users.noreply.github.com> Date: Mon, 6 Oct 2025 17:13:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20SQLite=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=AF=B9=E8=AF=9D=E5=92=8C?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E7=AE=A1=E7=90=86=E5=A2=9E=E5=8A=A0=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E9=98=B2=E6=8A=96=E6=9C=BA=E5=88=B6=20(#2969)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 优化 SQLite 数据库初始化设置并增强会话搜索功能,会话管理增加输入防抖 * fix: adjust SQLite cache and mmap size --------- Co-authored-by: Soulter <905617992@qq.com> --- astrbot/core/db/sqlite.py | 7 + dashboard/src/views/ConversationPage.vue | 181 +++++++++--------- dashboard/src/views/SessionManagementPage.vue | 5 +- 3 files changed, 105 insertions(+), 88 deletions(-) diff --git a/astrbot/core/db/sqlite.py b/astrbot/core/db/sqlite.py index d8c1684a7..f9faede19 100644 --- a/astrbot/core/db/sqlite.py +++ b/astrbot/core/db/sqlite.py @@ -32,6 +32,12 @@ class SQLiteDatabase(BaseDatabase): """Initialize the database by creating tables if they do not exist.""" async with self.engine.begin() as conn: await conn.run_sync(SQLModel.metadata.create_all) + await conn.execute(text("PRAGMA journal_mode=WAL")) + await conn.execute(text("PRAGMA synchronous=NORMAL")) + await conn.execute(text("PRAGMA cache_size=20000")) + await conn.execute(text("PRAGMA temp_store=MEMORY")) + await conn.execute(text("PRAGMA mmap_size=134217728")) + await conn.execute(text("PRAGMA optimize")) await conn.commit() # ==== @@ -160,6 +166,7 @@ class SQLiteDatabase(BaseDatabase): col(ConversationV2.title).ilike(f"%{search_query}%"), col(ConversationV2.content).ilike(f"%{search_query}%"), col(ConversationV2.user_id).ilike(f"%{search_query}%"), + col(ConversationV2.conversation_id).ilike(f"%{search_query}%"), ) ) if "message_types" in kwargs and len(kwargs["message_types"]) > 0: diff --git a/dashboard/src/views/ConversationPage.vue b/dashboard/src/views/ConversationPage.vue index 35242db78..753cd735f 100644 --- a/dashboard/src/views/ConversationPage.vue +++ b/dashboard/src/views/ConversationPage.vue @@ -10,7 +10,7 @@ + density="compact" hide-details>