V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
TomeWong
V2EX  ›  程序员

electron web worker 将上传返回的状态信息插入和更新到数据库中,查询效果比较低

  •  
  •   TomeWong · May 20, 2020 · 1618 views
    This topic created in 2169 days ago, the information mentioned may be changed or developed.

    目前是在 web worker 中处理上传的文件,在 worker 主线程中将读取到的文件信息插入到 sqlite 中,将每个

    文件上传成功后的信息返回至 worker 主线程中,然后在 worker 主线程中将更新的信息插入到数据库中。由于上

    传和数据插入,数据更新是两个独立的异步过程,无法专门控制。现在是上传 2 万+小文件,在 web worker 中上传是

    非常快的( 1s 中,可以上传 10+文件),而 sqlite 更新较慢,其查询也较慢,如果同时存在更新和查询,每次查询

    的时间会操作 2s,如果仅仅是查询就需要 170ms,查询的效率较低,一下是查询语句

    select * from store_db where status='SEARCHING' or status='UPLOADING' or status='WAITING'

    页面中显示上传进度信息是通过查询 sqlite 来获取的,导致上传和渲染是不同步的

    各位大佬有遇到这种情况么?

    谢谢!

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5630 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 07:09 · PVG 15:09 · LAX 00:09 · JFK 03:09
    ♥ Do have faith in what you're doing.