Why is mongodb 5 times slower than mysql?


there is a system that plans to migrate from php+mysql to nodejs+mongodb
, but as shown in the figure, the query efficiency of the same 2001 pieces of data is 5 times different, and the data structure is exactly the same. is this normal? It feels totally unacceptable.
is there any place where the posture is incorrect?
is like having encountered windows platform localhost when you first contacted php . 127.0.0.1 slow N times as the pit, mongodb whether there is such a hidden pit

.
Jan.10,2022

finally found the reason, because mine is Mongoose , and its find internal Mongoose Documents conversion causes
plus lean to directly return ordinary javascript objects, instead of Mongoose Documents to soar in efficiency. I hope it will be helpful to the later

.
const list = await Customer.find().lean();



the above figure compares the efficiency of lean with that of mysql . Two databases of 2000 items and 30000 items of data are tested twice. In the case of a large amount of data, it still seems to have a gap with mysql , but it is within an acceptable range

.

say more mongoose without lean to find 30000 + pieces of data. That library can directly overflow node memory

.
Menu