To add to other comments, "all" should also be an option, not just an integer sample count. Frequently, the exhaustiveness of the output schema is the point of using it.
This possibly impacts how it works in the first place, as it wouldn't be even using $sample at all, it should cursor over all the docs.
I've been personally using this extremely handy utility https://github.com/mongoeye/mongoeye for my analysis, but it's using outdated driver that doesn't work anymore with newer MongoDB versions.
To add to other comments, "all" should also be an option, not just an integer sample count. Frequently, the exhaustiveness of the output schema is the point of using it.
This possibly impacts how it works in the first place, as it wouldn't be even using $sample at all, it should cursor over all the docs.
I've been personally using this extremely handy utility https://github.com/mongoeye/mongoeye for my analysis, but it's using outdated driver that doesn't work anymore with newer MongoDB versions.