Implement Model::estimatedCount() for performance needs

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Laravel, Performance
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Follow https://github.com/mongodb/laravel-mongodb/issues/2626

      In PHPORM-50, the implementation of Builder::count() was modified to not use the deprecated Collection::count(), but the new Collection::countDocuments(). This have a negative impact on performance when people needs to count all documents of a collection.

      Proposition: Add a new method Builder::estimatedCount() that it can also be used from the model: Model::estimatedCount().

      We need to throw an exception if this method is used while the query builder have $wheres predicated, because that's not supported by MongoDB Server.

       

       

              Assignee:
              Unassigned
              Reporter:
              Jérôme Tamarelle
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: