Is it OK to mixed NumberLong and normal integers in the same field in MongoDB?

Posted by Nicholas Tolley Cottrell on Stack Overflow See other posts from Stack Overflow or by Nicholas Tolley Cottrell
Published on 2012-04-12T11:26:11Z Indexed on 2012/04/12 11:28 UTC
Read the original article Hit count: 229

Filed under:

I have been using Morphia to persistent objects from Java. I have also been running some batch processes from the console. I just realised that some values are now stored as NumberLong and number as plain Javascript numbers.

I have an index on this field. Everything seems to be ok, but if I query: {f: 100} from the console it still returns the object even if it actually contains {f: NumberLong(100)}

Is this true of all the drivers? It is best practice to avoid NumberLong is I can fit the value inside 32-bit? Will I save a lot of data and index space if I convert all NumberLongs to basic numbers?

© Stack Overflow or respective owner

Related posts about mongodb