K
K
Konstantin2020-12-06 00:03:04
MongoDB
Konstantin, 2020-12-06 00:03:04

Mongodb pull all colors - performance?

There is a collection of cars with a color field:

"color": ["#ccc", "#fff", "#000", ...]

Documents in a collection with cars can be about 1 million. Each car has its own color or several possible ones.

The task is to show all the unique colors that cars have.

As I understand it, you need to make a request to the cars collection and pull out unique values ​​from the color field in each record.

How efficiently does Mongodb deal with this, given the correct placement of indexes, and how correct is such a query in the forehead?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question