ReadConcern Available vs ReadPreference Nearest

Can you explain the difference between ReadConcern Available vs ReadPreference Nearest?

These two things seem to imply the same thing.

It is quite complex and it is best to refer to the professionally written documentation.

and

You certainly may ask for clarification on what is written over there. There is a green button at the bottom right of the page to provide feedback if you feel the manual page is not sufficient.

Hi @Altiano_Gerung,

I think to answer your question you first need to understand the difference between a readConcern and a readPreference.

The readConcern implies what level of durability are you expecting from the documents read. For example readConcern available will return any available document in the connected node, regardless of readPreference (you can be on a secondary or primary based on your preference).

The readPreference implies which nodes are eligible for he connection to be established on. For example the nearest means that the connection is tested for ping latency and node with lowest number will be chosen.

You can still try to find majority commited data when reading on that node, regardless if its primary or secondary if your readConcern is default majority.

Hope it helps.

Thanks
Pavel

1 Like