1

それぞれ 2000 レコードの配列を持つ 150 個のドキュメントの取得をテストしました。
これはメモリ使用量です:

Memory after collection: 1584
Memory after findOne: 530936
Memory after find: 81798960

したがって、findOne は約 0.5MB を使用しますが、150 個のドキュメントを検索するには 78MB を使用します。

このようにメモリ使用量が多いのは正常ですか? または、ドキュメント オブジェクトが大きすぎますか? 2000 レコードのそれぞれに 4 文字ほど格納しています。

テストに使用したコード:

<?php
    $old = memory_get_usage();
    $collection = $mongo->getMongoCollection($this->Mb);
    $new = memory_get_usage();
    echo "Memory after collection: " . ($new - $old) . "<br>";

    $old = memory_get_usage();
    $arr = $collection->findOne(array('capture' => '1367208145'));
    $new = memory_get_usage();
    echo "Memory after findOne: " . ($new - $old) . "<br>";

    $old = memory_get_usage();
    $cursor = $collection->find();
    $arr = iterator_to_array($cursor);
    $new = memory_get_usage();
    echo "Memory after find: " . ($new - $old) . "<br>";
?>
4

0 に答える 0