V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
LeeReamond
V2EX  ›  问与答

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

  •  
  •   LeeReamond · 2021-12-30 00:00:52 +08:00 · 1098 次点击
    这是一个创建于 872 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    6 条回复    2021-12-31 14:32:21 +08:00
    kingxiangqi
        1
    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
        2
    kingxiangqi  
       2021-12-30 00:52:02 +08:00   ❤️ 1
    上面是官方物理限制,实际上很难达到这些限制。
    另外建议参考: https://www.sqlite.org/whentouse.html
    说一下个人意见,这个量级完全不用担心性能问题。小马过河,完全可以在实践中自行尝试和优化。sqlite 的好处就是数据库是文件级别的,很方便,假设有性能问题,您的数据又是独立良好分离的,分表不行还可以分文件(库),没有什么需要担心的。
    wellsc
        3
    wellsc  
       2021-12-30 09:11:53 +08:00
    你这写入量已经比很多公司上线项目的量还多了,赶紧搞分布式吧[狗头]
    815979670
        4
    815979670  
       2021-12-30 10:53:52 +08:00
    每天数据量在 10w 量级 用 SQLite 数据库?单文件吗,sqlite 性能这么强大?
    LeeReamond
        5
    LeeReamond  
    OP
       2021-12-31 14:27:04 +08:00
    @815979670 拆分业务也就处理最近几天的内容,1-2 百万条吧,sqlite 处理这个数量级比较轻,ms 内存占的比较多
    815979670
        6
    815979670  
       2021-12-31 14:32:21 +08:00
    @LeeReamond 这么一说我对 SQLite 感兴趣了,写一些简单的内部项目感觉 sqlite 就够用了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3547 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 05:17 · PVG 13:17 · LAX 22:17 · JFK 01:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.