[SERVER-29067] Extend listIndexes to support listing all indexes for a database Created: 04/May/17  Updated: 07/Apr/23

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Dusty Burwell Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Participants:

 Description   

The original proposal below was to support this with new syntax {listIndexes: "*"}. Another option is to add $listIndexes support to the agg framework and allow such pipelines to be specified over an entire database by omitting the collection name:

myDB.runCommand({aggregate: 1, cursor: {}, pipeline: [{$listIndexes: {}}, ...]});

Original description

We've found that we needed the ability to get all indexes for a db, similar to how we used to be able to query "system.indexes". We've patched mongod to enable this with the command `{'listIndexes': '*'}`.

Would anyone be interested in us submitting this to upstream?



 Comments   
Comment by David Bartley [ 02/Aug/19 ]

Hello, was just curious if there's been any progress on this, or if there was interest in us sending a patch upstream for the original listIndexes: "*" proposal?

Comment by David Storch [ 08/May/17 ]

Hi dustyburwell,

Thanks for filing this feature request and for your willingness to upstream code changes that you've found useful. This is something which we would like the MongoDB server to support in the future. However, we have tentative plans to move listIndexes support into the aggregation framework, by introducing a new $listIndexes aggregation data source. This would be akin to existing metadata agg sources such as $indexStats and $collStats.

In addition, we are tentatively considering changes that will allow some special aggregation data sources to omit the collection, in order to indicate that the agg source should apply to the database as a whole. In the event that both the $listIndexes agg source and aggregations over a whole database rather than just a single collection are implemented for versions 3.6 or 3.8, we would prefer to support "list all indexes for a database" via the aggregation framework. This would be instead of implementing the proposed {listIndexes: "*"} syntax.

Since the patch would conflict with our future plans, I do not think we would accept this code upstream at the moment. Plans and priorities are always subject to change though, in which case we will re-evaluate this decision! For the time being, I am going to convert this ticket into a feature request which does not specify the exact {listIndexes: "*"} user-facing syntax. Let me know if you have any questions or concerns.

Best,
Dave

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