The PHP documentation for the mongo class says using a cursor instead of iterator_to_array
is superior.
Why? What benefits/flexibility will I get from that?
The PHP documentation for the mongo class says using a cursor instead of iterator_to_array
is superior.
Why? What benefits/flexibility will I get from that?
Copyright © 2021 Jogjafile Inc.
Using
iterator_to_array()
makes your driver load all of the results into memory at once, and you could easily run out of memory. This would not be the case with a cursor, which uses lazy-loading!Straight from the linked docs: