Home > other >  Why do I use golang read directing the above data, read article 101 withdrew from the loop?
Why do I use golang read directing the above data, read article 101 withdrew from the loop?

Time:04-26

Eldest hello, I use a lot of mongo - go - driver connected mongo,

Baidu for a long time, I know mongo default read-only 101 records every time out,

Because at present a total of more than 30000 records in the database, so I put the BatchSize set to 40000, at present my solution is this:

 
Max_record:=int32 (40000)
Cursor, err:=video_collection. Find (context. The Background (), the filter, the options. The Find () SetBatchSize (max_record))



But later if the number of records of more than 40000 or more, I can only compile again,

But I also fear that would take up too much memory (is currently takes up about 1 g, barely hold up),

Because I am a novice, please help to look at, how to write can make golang read all of the records?
  • Related