Mybatis and SQL nested subquery pit

Recently, I encountered a production problem.
After analysis, I found that one request call and executed many SQL queries. It
is because of the use of nested query writing in mybatis, which became the problem.

The reason is that the returned data requires the format
class A {
XXX a1
xxxx a2
List list
}

Developers to query the record satisfies a1 and a2, then in order to save, in mybatis resutlMap return value written when,
on the use of nested query




</>

This writing method is no problem when the number of records returned by a1 a2 is not large, but the amount of data is large, it is necessary to execute SQL as many times as there are rows of records, and use this situation with caution. The number of records returned is Limit n. It
cannot be used to export such a scenario without Limit in full.

Published 331 original articles · 51 praises · 440,000 visits +

Guess you like

Origin blog.csdn.net/y41992910/article/details/105105510