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

Validate parameters for estimatedDocumentCount

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization

      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?

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            jason.coombs@yougov.com Jason R. Coombs
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: