提交 c57fb7c9 authored 作者: Andrei Tokar's avatar Andrei Tokar

miniscule optimisation

上级 b03f027c
...@@ -593,28 +593,23 @@ public class Select extends Query { ...@@ -593,28 +593,23 @@ public class Select extends Query {
limitRows += offset; limitRows += offset;
} }
} }
ArrayList<Row> forUpdateRows = null; ArrayList<Row> forUpdateRows = this.isForUpdateMvcc ? Utils.<Row>newSmallArrayList() : null;
boolean lockRows = this.isForUpdateMvcc;
if (lockRows) {
forUpdateRows = Utils.newSmallArrayList();
}
int sampleSize = getSampleSizeValue(session); int sampleSize = getSampleSizeValue(session);
LazyResultQueryFlat lazyResult = new LazyResultQueryFlat(expressionArray, LazyResultQueryFlat lazyResult = new LazyResultQueryFlat(expressionArray,
sampleSize, columnCount); sampleSize, columnCount);
if (result == null) { if (result == null) {
return lazyResult; return lazyResult;
} }
while (lazyResult.next()) { if (sort != null && !sortUsingIndex || limitRows <= 0) {
if (lockRows) { limitRows = Long.MAX_VALUE;
}
while (result.getRowCount() < limitRows && lazyResult.next()) {
if (forUpdateRows != null) {
topTableFilter.lockRowAdd(forUpdateRows); topTableFilter.lockRowAdd(forUpdateRows);
} }
result.addRow(lazyResult.currentRow()); result.addRow(lazyResult.currentRow());
if ((sort == null || sortUsingIndex) && limitRows > 0 &&
result.getRowCount() >= limitRows) {
break;
}
} }
if (lockRows) { if (forUpdateRows != null) {
topTableFilter.lockRows(forUpdateRows); topTableFilter.lockRows(forUpdateRows);
} }
return null; return null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论