MongoDB select count(distinct x) on an indexed column - count unique results for large data sets

前端 未结 3 1439
感情败类
感情败类 2020-11-28 19:51

I have gone through several articles and examples, and have yet to find an efficient way to do this SQL query in MongoDB (where there are millions of rows documen

3条回答
  •  孤独总比滥情好
    2020-11-28 20:42

    Following solution worked for me

    db.test.distinct('user'); [ "alex", "England", "France", "Australia" ]

    db.countries.distinct('country').length 4

提交回复
热议问题