Implement Model::estimatedCount() for performance needs

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Won't Do
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Laravel, Performance
    • None
    • 🔵 Done
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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:
              Resolved: