提交 b8401436 authored 作者: Thomas Mueller's avatar Thomas Mueller

Conditions such as ID=? AND ID>? were slow.

上级 58b756e3
...@@ -225,6 +225,19 @@ public class TableFilter implements ColumnResolver { ...@@ -225,6 +225,19 @@ public class TableFilter implements ColumnResolver {
state = BEFORE_FIRST; state = BEFORE_FIRST;
foundOne = false; foundOne = false;
} }
private Value getMax(Value a, Value b, boolean bigger) throws SQLException {
if (a == null) {
return b;
} else if (b == null) {
return a;
}
int comp = a.compareTo(b, session.getDatabase().getCompareMode());
if (!bigger) {
comp = -comp;
}
return comp > 0 ? a : b;
}
/** /**
* Check if there are more rows to read. * Check if there are more rows to read.
...@@ -257,18 +270,24 @@ public class TableFilter implements ColumnResolver { ...@@ -257,18 +270,24 @@ public class TableFilter implements ColumnResolver {
isEnd = temp; isEnd = temp;
} }
if (isStart) { if (isStart) {
// TODO index: start.setExpression(id, bigger(start.getValue(id), e)); Value newStart;
if (start == null) { if (start == null) {
start = table.getTemplateRow(); start = table.getTemplateRow();
newStart = v;
} else {
newStart = getMax(start.getValue(id), v, true);
} }
start.setValue(id, v); start.setValue(id, newStart);
} }
if (isEnd) { if (isEnd) {
// TODO index: end.setExpression(id, smaller(end.getExpression(id), e)); Value newEnd;
if (end == null) { if (end == null) {
end = table.getTemplateRow(); end = table.getTemplateRow();
newEnd = v;
} else {
newEnd = getMax(end.getValue(id), v, false);
} }
end.setValue(id, v); end.setValue(id, newEnd);
} }
} }
if (!alwaysFalse) { if (!alwaysFalse) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论