This is written in many paging programs:
SELECT COUNT (*) from ' table ' WHERE ...; Find out the total number of records that meet the criteria select * from ' table ' WHERE ... limit m,n; Query the data to be displayed on the page such statements can be changed to: Sql1:select sql_calc_found_rows * from ' table ' WHERE ... limit M, N;
Sql2:select found_rows ();
So as long as the execution of a more time-consuming complex query can get the same number of records with no limit, but this kind of processing I fear is unsafe "guess, not verified": in the case of connection pool, when the SQL1 execution end, if the buffer value in the SQL2 is removed quickly, it is basically correct, However, if there are other processes taking this intermediate result at this point, it is clear that the result of the SQL2 query is incorrect. So, Scenario 1 is safer than Scenario 2? Let me have the time to verify the next.
is Spring JDBC found_rows secure?