[SERVER-16521] Make listCollections() an aggregation source Created: 11/Dec/14  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Usability
Affects Version/s: 2.8.0-rc2
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Hannes Magnusson Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-16524 Unable to do system.namespace collect... Closed
Related
is related to SERVER-14707 listCollections and listIndexes comma... Closed
Assigned Teams:
Query Execution
Backwards Compatibility: Major Change
Participants:

 Description   

Before the listCollections command came about, drivers/users could run a count on systems.collections to find how many collections are in a database.

Moving to use dbStats now, but that returns how many collections are in a database, total.
In mmapv1 you have to -2 as there are two system collections.
Using WiredTiger, the number reflects how many user collections there.

This is a request to make the number of user collections available somehow, likely in dbStats.

Getting a count with a filter/query is needed too.



 Comments   
Comment by Hannes Magnusson [ 13/Dec/14 ]

I am not aware of an actual helper that does this in drivers. It just came up as an interesting side effect of being a command now - how can we know how many results a command cursor has?
We can't pass the query into count (although that'd be interesting - passing a cursor_id to it), like with normal cursors. The only actual usecase for this though I could think of atm was admin tools that may have already used dbStats rather then counting the collection.

Comment by Scott Hernandez (Inactive) [ 12/Dec/14 ]

The current way to do this is to count on the client. We will evaluate if this is sufficient or if doing the count on the server is needed, without sending the client the actual data.

Comment by Christian Amor Kvalheim [ 12/Dec/14 ]

It's not a client side api that's the issue it's using the normal count command on the system.namespace collection. I don't know if people are using this or not but we should probably verify the risk of not allowing collection name count.

of the top of the head I can imagine some "admin" tools for mongodb does something like this to show stats.

Comment by Scott Hernandez (Inactive) [ 12/Dec/14 ]

bjori, christkv, what client APIs exist today that need this? In both php and node.js I only see listCollection type functions.

Generated at Thu Feb 08 03:41:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.