How does node.js use mongodb to make high-performance multi-concatenated table queries?

< H2 > for example, there are two tables < / H2 >

student Table
id-> user id
name-> user name
classId-> Class id

class Table
id-> Class id
name-> Class name

if I want to query the information of all the students and the class information they belong to, I can use mongodb"s join table query method $lookup
but many friends on the Internet say that the performance of mongodb is not good , so I think of a way

< H2 > Plan 1: < / H2 >

each time the student information is queried, the class table is queried according to classid, and then the data is returned. But in this way, if there are another 100 pieces of data, 200 queries will be made. It doesn"t look good either.

< H2 > Plan 2: < / H2 >

I don"t know if there is such a way. First, query all the student, then take all the classId out and put them into the array, and then use the query method of the classsId in class table in mysql to query, so that only two queries are needed.

< H2 > which is more suitable? < / H2 >

an array of student should be saved in a nested document class

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c275e8-33855.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c275e8-33855.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?