我正在尝试提高 api 的性能。我需要知道标记的第二行是否也会命中数据库?因为我想尽量减少它。
StringBuffer queryBuf = new StringBuffer("some query in SQL");
--------->StringBuffer queryBuf2 = new StringBuffer(" SELECT DISTINCT PP.ID FROM ( " + queryBuf + ") PP ");
Query query1 = getSession().createSQLQuery(queryBuf2.toString());
query1.setReadOnly(true);
ScrollableResults results = query1.scroll();
if (results.isLast() == false)
results.last();
int total = results.getRowNumber() + 1;
results.close();
logger.debug(">>>>>>TOTAL COUNT<<<<<< = {}", total);