LeeReamond
V2EX  ›  问与答

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

  •  
  •   LeeReamond · Dec 30, 2021 · 1894 views
    This topic created in 1770 days ago, the information mentioned may be changed or developed.

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

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

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

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