dapengzhao
V2EX  ›  问与答

大佬们有没有 mongodb 写入优化的经验,目前 10 个线程 1 小时才写入 40 万条数据

  •  
  •   dapengzhao · Jul 12, 2019 · 1457 views
    This topic created in 2560 days ago, the information mentioned may be changed or developed.

    def insert_data(conn): while not traffic_queue.empty(): conn.xadz.insert_one(traffic_queue.get())

    这是写入函数,把处理好的数据放到了队列里面

    jifengg
        1
    jifengg  
       Jul 12, 2019
    mongodb 支持批量写入,不要一次一条写
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   992 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 19:14 · PVG 03:14 · LAX 12:14 · JFK 15:14
    ♥ Do have faith in what you're doing.