[SERVER-54800] Support $indexStats aggregation stage for time-series collections Created: 25/Feb/21  Updated: 29/Oct/23  Resolved: 29/Mar/21

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
Related
related to SERVER-56095 remove redundant file exclusion for i... Closed
is related to SERVER-53290 Replace $function Unpacking in Timese... Closed
is related to SERVER-54645 Support listIndexes for time-series c... Closed
is related to SERVER-54990 Complete TODO listed in SERVER-54639 Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-04-05
Participants:

 Description   

Applications have to access the underlying bucket collection to inspect the indexes on a time-series collection. It would be convenient to be able to use the $indexStats aggregation stage on the time-series collections for the same purpose.



 Comments   
Comment by Githook User [ 26/Mar/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-54800 support $indexStats on time-series collections
Branch: master
https://github.com/mongodb/mongo/commit/b590f02173505b3dbeda07b3cd0925c4ae41713c

Comment by Githook User [ 26/Mar/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-54800 add js test for $indexStats on time-series collections
Branch: master
https://github.com/mongodb/mongo/commit/0ed54fe49b0195a8d82fc1d082f4aa5f3b9687dc

Comment by Githook User [ 26/Mar/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-54800 add aggregation stage to convert buckets schema index stats to time-series schema index stats
Branch: master
https://github.com/mongodb/mongo/commit/c5409d145836142f2af92c3e01b4f261e84d21c9

Comment by Githook User [ 26/Mar/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-54800 move timeseries::getTimeseriesOptions() into its own library
Branch: master
https://github.com/mongodb/mongo/commit/de4ce4b0bdf9412e4c9ed254a7215b3bdc709e21

Comment by Benety Goh [ 27/Feb/21 ]

Current $indexStats behavior on a time-series collection (with additional diagnostic messages in pipeline.cpp):

foo:PRIMARY> db.t.aggregate([{$indexStats: {}}])
uncaught exception: Error: command failed: {
	"ok" : 0,
	"errmsg" : "$indexStats is only valid as the first stage in a pipeline: { pipeline: [ { $_internalUnpackBucket: { exclude: [], timeField: \"tm\" } }, { $indexStats: {} } ] }",
	"code" : 40602,
	"codeName" : "Location40602",
	"$clusterTime" : {
		"clusterTime" : Timestamp(1614442215, 2),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1614442215, 2)
} with original command request: {
	"aggregate" : "t",
	"pipeline" : [
		{
			"$indexStats" : {
				
			}
		}
	],
	"cursor" : {
		
	},
	"lsid" : {
		"id" : UUID("66a9152b-37f1-4177-9032-21943efc0b17")
	},
	"$clusterTime" : {
		"clusterTime" : Timestamp(1614442215, 2),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	}
} 

Comment by Benety Goh [ 27/Feb/21 ]

According to the $indexStats (aggregation) documentation in the MongoDB Manual, $indexStats must be the first stage in an aggregation pipeline.

Generated at Thu Feb 08 05:34:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.