Since upgrading to MongoDB 2.2 and the version 1.3 PECL package for Mongo (not sure which change is relevant), I’ve noticed that inserts through PHP for fields cast to ints are now inserted as NumberLong in our collections ( {“userid” : NumberLong(792)} ). Previously, they were inserted as integers( {“userid” : 792} ). And, while new records use NumberLong now, our collections are now mixed, with like fields having unlike types.
Is this likely to cause problems, particularly with indexing and finding? Is one format preferred (I assume NumberLong is preferred)? Is there a straightforward way to update our collections to the new format, assuming that is a good idea?
For the purposes of querying, you should not have any problem with numeric fields of varying types. Integers, longs, and doubles all undergo conversion before being compared. Likewise, if you had a unique index on some numeric field
x, you would receive an error attempting to insert two documents with values1and1.0forx. This is mentioned in the Compare Order for BSON Types documentation.