关系型数据库表的数量如果增加到很多很多,是否会影响性能?

2021-12-30 00:00:52 +08:00
 LeeReamond

如题,目前手里有个小应用,用的是 sqlite 做数据库。

现在业务上每天新增条目数大概在 10 万这个量级,业务上每天内容是独立的,所以我把每天都拆分成一个独立的表,目前使用还是挺好的。

有没有老哥试过比如业务数据持续增大以后,比如三年以后增长到 1000+的表,是否会影响数据库的性能表现

1103 次点击
所在节点    问与答
6 条回复
kingxiangqi
2021-12-30 00:25:44 +08:00
https://sqlite.org/limits.html

15.Maximum Number Of Tables In A Schema

Each table and index requires at least one page in the database file. An "index" in the previous sentence means an index created explicitly using a CREATE INDEX statement or implicit indices created by UNIQUE and PRIMARY KEY constraints. Since the maximum number of pages in a database file is 2147483646 (a little over 2 billion) this is also then an upper bound on the number of tables and indices in a schema.

Whenever a database is opened, the entire schema is scanned and parsed and a parse tree for the schema is held in memory. That means that database connection startup time and initial memory usage is proportional to the size of the schema.
kingxiangqi
2021-12-30 00:52:02 +08:00
上面是官方物理限制,实际上很难达到这些限制。
另外建议参考: https://www.sqlite.org/whentouse.html
说一下个人意见,这个量级完全不用担心性能问题。小马过河,完全可以在实践中自行尝试和优化。sqlite 的好处就是数据库是文件级别的,很方便,假设有性能问题,您的数据又是独立良好分离的,分表不行还可以分文件(库),没有什么需要担心的。
wellsc
2021-12-30 09:11:53 +08:00
你这写入量已经比很多公司上线项目的量还多了,赶紧搞分布式吧[狗头]
815979670
2021-12-30 10:53:52 +08:00
每天数据量在 10w 量级 用 SQLite 数据库?单文件吗,sqlite 性能这么强大?
LeeReamond
2021-12-31 14:27:04 +08:00
@815979670 拆分业务也就处理最近几天的内容,1-2 百万条吧,sqlite 处理这个数量级比较轻,ms 内存占的比较多
815979670
2021-12-31 14:32:21 +08:00
@LeeReamond 这么一说我对 SQLite 感兴趣了,写一些简单的内部项目感觉 sqlite 就够用了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/825179

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX