Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40718

Validate parameters for estimatedDocumentCount

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Query Optimization

    Description

      The documentation for `estimatedDocumentCount` is a bit confusing.

      It seems that both MongoDB (shell) and PyMongo allow passing arbitrary, meaningless options. In PyMongo, I've been calling the function thus:

      db.coll.estimated_document_count(
              filter=query, limit=limit, maxTimeMS=10000)
      
      

      Not realizing that the filter and limit had no effect.

      I've tested and the shell also silently accepts arbitrary fields:

      rs0:PRIMARY> db.coll.estimatedDocumentCount({"foo": "bar"})
      1
      
      

      I try to imagine what is the value of accepting arbitrary keyword arguments. I could imagine that some future version of MongoDB might honor other parameters for that query, so you'd like to support that interface before it exists. Even for that use-case, I'd expect the server to respond with some warning or errors about unused parameters, especially when the docs say "this method wraps the count command", which does take more parameters.

      Can this call be made so that it rejects invalid parameters?

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            jason.coombs@yougov.com Jason R. Coombs
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: