search

Home  >  Q&A  >  body text

mongodb中,对于一个大集合,如何做到每次只取一点,分段取完一个集合?

集合的查询带条件的,条件可能会变,如果是mysql的话,可以通过简单记录ID来做到,以后取只取比这个id大的,但是mongodb不知道该如何做?

仅有的幸福仅有的幸福2800 days ago803

reply all(1)I'll reply

  • 某草草

    某草草2017-04-25 09:04:22

    1. Like mysql, you can add a long-type redundant field, incrementing each time, so that you can solve the problem that the mongo primary key is of type ObjectId;
    2. You can use paging to do it, but you may need to record how much data has been fetched in previous segments. If the same amount of data is fetched in each segment, it is more suitable for paging.

    reply
    0
  • Cancelreply