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

FastApi 同样的代码 Sqlite 为什么比 mysql 慢那么多

  •  
  •   szxczyc · 2022-10-10 11:40:32 +08:00 · 823 次点击
    这是一个创建于 566 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用的 sqlalchemy ,每次 insert 慢的离谱~

    1 条回复    2022-10-10 15:42:42 +08:00
    uglyer
        1
    uglyer  
       2022-10-10 15:42:42 +08:00   ❤️ 1
    可以把具体的表结构以及插入记录和执行时长贴出来具体分析一下。

    设置 PRAGMA synchronous = OFF 和 PRAGMA journal_mode=WAL 后,我本机测试(m1) sqlite 单表连续插入每秒能到 6 万多条 CREATE TABLE foo (id integer not null primary key, name text); INSERT INTO foo(name) VALUES(?)

    另外,使用预编译语句也能提升一些性能。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1553 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:55 · PVG 00:55 · LAX 09:55 · JFK 12:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.