Get the App
SLTechnology News&Howtos  ›  Database  › 

MongoDB in quantity limit

Shulou Source: shulou.com Published: 2022-06-01 05:16:36 10月01日 Update

1. The query statement itself is actually a document, with a maximum of 16MB (3.4, official documentation)

2. The query statement itself, that is, {': {'$in': []}}, has a size of 22 bytes

3. Add one byte for each additional field name

4. For each additional parameter in the in, the size increases by 11 bytes.

5. As follows:

Mongos > Object.bsonsize ([1])

sixteen

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4]}})

seventy-four

Mongos > Object.bsonsize ({'fieldOne': {$in: [1, 2, 3, 4, 5]})

eighty-five

Mongos > Object.bsonsize ({'fieldOne': {$in: [1, 2, 3, 4, 5, 6]})

ninety-six

Mongos > Object.bsonsize ({'fieldOne': {$in: [1, 2, 3, 4, 5, 6, 69000]}})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1, 2, 3, 4, 5, 6, 6900000]}})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,69000000000]})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,69000000000000]})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,6900000000000000]})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,690000000000000000]})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,69000000000000000000]})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,690000000000000000000000]})

one hundred and seven

Mongos > Object.bsonsize ({'fieldOne': {$in: [1,2,3,4,5,6,690000000000000000000000000000]})

one hundred and seven

No matter how big the number is, the bytes are the same.

Mongos > Object.bsonsize ({'a': {'$in': [1]}})

thirty-four

Mongos > Object.bsonsize ({'': {'$in': [1]}})

thirty-three

Mongos > Object.bsonsize ({'': {'$in': []}})

twenty-two

The query document itself is 22 bytes

Each byte of the field name adds a single byte

Each number added to the $in clause adds 11 bytes.

Mongos > 16 "1024" 1024

16777216

Mongos > (16,1024,1024)-22-1

16777193

Mongos > (16,1024,1024)-22-1) / 11

1525199.3636363635

THE ANSWER: 1525198 (That's 1.5 million. That's pretty big.)

Tags: Bytes size statements queries limits maximum that is parameters fields official numbers documents plus one quantity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology Huawei MariaDB Linux