{
A: 1
B: null
}
vs
{
A: 1
}
Is there any differences between the 2 documents?
{
A: 1
B: null
}
vs
{
A: 1
}
Is there any differences between the 2 documents?
Of course there is a difference. Document with B: null
consumes little more space on your disk. Also if you like to query them, they are different, see Or with If and In mongodb
Comment from @Takis is not fully correct. When you create an index in MongoDB, then it indexes also documents where the field does not exist - unless you define a Sparse Index/Partial Index. This behavior is different to most relational SQL databases.