Spring mongoTemplate query is slow

the same query, using mongoTemplate will be much slower, using mongodb tool, looking at the execution plan is very fast, the difference is very big

Mar.20,2021

is there a solution now? I also found that the query speed is very slow.


  1. your two screenshots don't seem to execute a query (at least the second screenshot has sort, and the first Java code doesn't).
  2. because it does not specify what graphical interface this is, and the execution plan is folded and invisible, it is impossible to determine whether the 50 on the second screenshot represents whether it affects the execution plan to take only the first 50 results. By contrast, the Java code takes out all the results. This can make a big time difference.

finally, a few additional suggestions have nothing to do with the topic. Code, logs, execution results, and so on, that can be pasted with text, are all pasted out with text. Not only does the picture look inconvenient, but sometimes incomplete truncation is also very disadvantageous for us to answer questions. And sometimes we need to use your code, data, etc., to do testing, if there are only screenshots at this time, basically a lot of people will give up on the spot.


for too long, the description of the problem in this article is not clear. Please do not use this article as a reference

.
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-1b3753e-2c09c.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-1b3753e-2c09c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?