search

Home  >  Q&A  >  body text

MongoDB无法查询数据

MongoDB批量插入数据时,执行查询无法查询到数据,插入完成后才查询到数据

PHP中文网PHP中文网2768 days ago803

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-04-25 09:04:03

    This is something that mongodb has always been criticized for - read-write locks, and before version 2.2 it was global, that is, during write operations, the entire database was restricted from reading and writing. Later, collection-level locks were gradually supported. However, if you are talking about reading and writing the same collection, there is still no way to do it at the same time. I don't know if any engine supports document-level locks. So I'm sorry, I can't solve the problem you encountered. I think I can only avoid this situation from a business perspective, or divide the database into read-write separation.

    reply
    0
  • 習慣沉默

    習慣沉默2017-04-25 09:04:03

    From your description, you should be using a version before 2.8. Because document level locking is supported from 2.8 onwards. After 3.0, mongodb exited the WiredTiger engine. Different users can edit and query different documents in the same collection at any time. As for batch insertion queries, unless you want high-intensity concurrency. Basically, there is no problem with the read and write speed of mongodb. This is what he exists for.

    reply
    0
  • Cancelreply