Skip to content

perf: 启用 WAL 模式并添加 B-Tree 索引以加速查询#1253

Open
Moeblack wants to merge 1 commit into
EcoPasteHub:masterfrom
Moeblack:perf/wal-btree-indexes
Open

perf: 启用 WAL 模式并添加 B-Tree 索引以加速查询#1253
Moeblack wants to merge 1 commit into
EcoPasteHub:masterfrom
Moeblack:perf/wal-btree-indexes

Conversation

@Moeblack
Copy link
Copy Markdown

@Moeblack Moeblack commented Feb 6, 2026

概述

为大数据量用户优化查询性能。

改动

  1. WAL 模式PRAGMA journal_mode = WAL,读写并发,搜索时不阻塞剪贴板写入
  2. B-Tree 索引
    • idx_history_createTime:加速 ORDER BY createTime DESC LIMIT 分页查询
    • idx_history_group_createTime:加速按分组筛选 + 排序
    • idx_history_favorite_createTime:加速收藏筛选 + 排序

配合现有的分页查询(LIMIT 20),索引可以让 SQLite 沿索引顺序扫描并提前终止,减少不必要的全表扫描。

无副作用

  • 索引使用 IF NOT EXISTS,对已有数据库安全
  • WAL 模式是 SQLite 推荐的并发模式,无兼容性风险
  • 不改变任何查询逻辑,仅提供索引加速

相关 issues:#467

- 启用 WAL journal 模式,实现读写并发(搜索时不阻塞剪贴板写入)
- 添加 B-Tree 索引:createTime、group+createTime、favorite+createTime
- 配合分页查询(ORDER BY createTime DESC LIMIT),索引可显著减少扫描行数

相关 issues:EcoPasteHub#467
@Moeblack Moeblack force-pushed the perf/wal-btree-indexes branch from ef55cbc to 7566ce7 Compare February 6, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant