Amazon DocumentDB error "Aggregation stage not supported: '$collStats'"

1.5k Views Asked by At

I want to check compression ratio of my collection in Amazon DocumentDB, but when I run commands proposed in the docs https://docs.aws.amazon.com/documentdb/latest/developerguide/doc-compression.html : db.printCollectionStats() or db.collection.stats()

I get an error:

{ ok: 0, errmsg: "Aggregation stage not supported: '$collStats'" }

My cluster is using Engine version docdb 5.0.0.

I tried to run above commands from mongosh v 2.00 and NodeJS driver (mongodb v6.0.0) and got the same results.

2

There are 2 best solutions below

0
mkb On BEST ANSWER

Based on Supported MongoDB APIs, Operations, and Data Types link provided in ray's answer I found out that $collStats aggregation is not supported, but collStats command is.

mongosh and Node driver are using $collStats aggregation under the hood so it does not work with DocumentDB.

Instead, one need to invoke collStats command directly on db with collection name in parameter.

Example in mongosh:

db.runCommand({collStats:"myCollection", scale:1000000})
0
ray On

Per DocumentDB official document,

Command 3.6 4.0 5.0 Elastic cluster
$collStats No No No No

So $collStats is not supported in DocumentDB as of now, no matter which version you are using.