Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB differences between NumberLong and simple Integer?

Tags:

mongodb

What are the main differences (size, speed, etc) between the datatypes double, NumberLong, NumberInt or a simple Integer in MongoDB?

If I want to save a small fixed number (something between 0 and 1000) which data type should I use?

like image 317
Francisco Costa Avatar asked Jun 19 '13 07:06

Francisco Costa


People also ask

What is NumberLong in MongoDB?

NumberLong. The mongo shell treats all numbers as floating-point values by default. The mongo shell provides the NumberLong() wrapper to handle 64-bit integers. The NumberLong() wrapper accepts the long as a string: NumberLong("2090845886852")

What is ISODate in MongoDB?

ISODate() is a helper function that's built into to MongoDB and wraps the native JavaScript Date object. When you use the ISODate() constructor from the Mongo shell, it actually returns a JavaScript Date object.


1 Answers

NumberInt

By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberInt() constructor to explicitly specify 32-bit integers.

NumberLong

By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberLong() class to handle 64-bit integers.

The NumberLong() constructor accepts the long as a string:

NumberLong("2090845886852")

Source: http://docs.mongodb.org/manual/core/shell-types/

like image 70
Jayram Avatar answered Sep 18 '22 19:09

Jayram