# 新app得推倒重来了

**URL:** <https://forum.freemdict.com/t/topic/37083>\
**Category:** 闲聊吹水\
**Created:** [2025 年3 月 6 日 08:01 UTC](https://forum.freemdict.com/t/topic/37083 "2025-03-06T08:01:29Z")\
**Posts on this page:** 11\
**Page:** 3

<div class="post-metadata">

作者： ![ticik73803](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@ticik73803](https://forum.freemdict.com/u/ticik73803)\
发布日期： [2026 年3 月 22 日 16:43 UTC](https://forum.freemdict.com/t/topic/37083/42 "2026-03-22T16:43:43Z")

</div>

sqlite性能差？建index了吧，建了之后都是毫秒出结果的

---

<div class="post-metadata">

作者： ![ticik73803](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@ticik73803](https://forum.freemdict.com/u/ticik73803)\
发布日期： [2026 年3 月 22 日 16:46 UTC](https://forum.freemdict.com/t/topic/37083/43 "2026-03-22T16:46:00Z")

</div>

连fts都不到一毫秒[SQLite 4.0 as a Production Database: 2025 Benchmarks and Pitfalls | Markaicode](https://markaicode.com/sqlite-4-production-database-benchmarks-pitfalls/)

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2026 年3 月 22 日 17:09 UTC](https://forum.freemdict.com/t/topic/37083/44 "2026-03-22T17:09:04Z")

</div>

> [@last\_idol](#):
>
> 我也觉得物书堂不需要一次性提取几十万词头，不过这个软件就这么设计的。
> 
> 虽然 sqlite 的上下限都很高，但毕竟不是专门设计的词典格式，有些可以优化的地方比较隐晦，比如 sqlite 的词头如果按顺序写入读取的时候可以接近磁盘的速度，如果随机写入又要按顺序读取，速度可能会下降 10 倍不止。

SQLite 不是为词典这种高密度、顺序扫描场景优化的，自己设计的格式会更快。

---

<div class="post-metadata">

作者： ![ticik73803](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@ticik73803](https://forum.freemdict.com/u/ticik73803)\
发布日期： [2026 年3 月 22 日 17:28 UTC](https://forum.freemdict.com/t/topic/37083/45 "2026-03-22T17:28:48Z")

</div>

确实是，自己的格式更快更小。我只是觉得lz说的sqlite性能差导致不够用的说法存疑

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2026 年3 月 22 日 17:43 UTC](https://forum.freemdict.com/t/topic/37083/46 "2026-03-22T17:43:49Z")

</div>

一次性提取几十万词头，SQLite 在这种场景下根本不够看。你自己实验下就知道了，这个和索引没关系了，跟存储词头的物理布局强关联。SQLite 的页结构导致它没法支持块压缩， 在需要顺序大块读取的场景下，支持块压缩的自定义词典格式，读取速度可以接近磁盘极限。

---

<div class="post-metadata">

作者： ![ticik73803](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@ticik73803](https://forum.freemdict.com/u/ticik73803)\
发布日期： [2026 年3 月 22 日 17:52 UTC](https://forum.freemdict.com/t/topic/37083/47 "2026-03-22T17:52:41Z")

</div>

这个正是我没有搞明白的部分，为什么需要这么大量的词头。对于lz这种普通查词的app来说，词头一次几十个一般就够用了。不明白这个使用场景

---

<div class="post-metadata">

作者： ![ticik73803](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@ticik73803](https://forum.freemdict.com/u/ticik73803)\
发布日期： [2026 年3 月 22 日 17:58 UTC](https://forum.freemdict.com/t/topic/37083/48 "2026-03-22T17:58:51Z")

</div>

> [@MeigenChou](#):
>
> 为了解决索引内部排序和原书不一致的问题。  
> 假设一字头下有几百几千个词条，【一般】这个词按音序排列应该在前面。但般字的unicode码在CJK区靠后的位置，如果只读取前几十个索引很容易漏掉这个词条。后方索引排序就和原书完全不一样，像搜索s结尾的词都有几万条，需要将几万索引都读出来才可以展现和原书一样的结果。这是一个优秀的词典软件的必要特性。

如果是指这个，这是sqlite column带个collation就能解决的事情

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2026 年3 月 22 日 20:02 UTC](https://forum.freemdict.com/t/topic/37083/49 "2026-03-22T20:02:56Z")

</div>

用 collation 也一样，逻辑顺序和物理顺序不一致，读取速度快不起来。前面的讨论都是基于复刻物书堂的使用场景，如果不追求速度的话，用 sqlite 就可以了。

---

<div class="post-metadata">

作者： ![ticik73803](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@ticik73803](https://forum.freemdict.com/u/ticik73803)\
发布日期： [2026 年3 月 23 日 01:37 UTC](https://forum.freemdict.com/t/topic/37083/50 "2026-03-23T01:37:36Z")

</div>

明白了，我去研究研究物书堂情况

---

<div class="post-metadata">

作者： ![midzuki\_yuka](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/midzuki_yuka/32/83965_2.png) [@midzuki\_yuka](https://forum.freemdict.com/u/midzuki_yuka)\
发布日期： [2026 年3 月 23 日 02:11 UTC](https://forum.freemdict.com/t/topic/37083/51 "2026-03-23T02:11:06Z")

</div>

麻煩去用下物書堂，他那個結果欄都沒有顯式分頁。你用sqlite肯定複製不了这种特性。我現在大致實現了，當然是用的自己的格式，看另一個貼子。

---

<div class="post-metadata">

作者： ![mxdict](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@mxdict](https://forum.freemdict.com/u/mxdict)\
发布日期： [2026 年6 月 28 日 11:42 UTC](https://forum.freemdict.com/t/topic/37083/52 "2026-06-28T11:42:48Z")

</div>

我也写了一个，欢迎交流。  
[https://forum.freemdict.com/t/topic/44435](https://forum.freemdict.com/t/topic/44435)

[上一页](https://forum.freemdict.com/t/topic/37083.md?page=2)
