szxczyc
V2EX  ›  问与答

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

  •  
  •   szxczyc · Oct 10, 2022 · 1628 views
    This topic created in 1311 days ago, the information mentioned may be changed or developed.

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

    1 replies    2022-10-10 15:42:42 +08:00
    uglyer
        1
    uglyer  
       Oct 10, 2022   ❤️ 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(?)

    另外,使用预编译语句也能提升一些性能。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5651 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 07:31 · PVG 15:31 · LAX 00:31 · JFK 03:31
    ♥ Do have faith in what you're doing.