提交 77bd2516 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add Index.isFindSlow() and use it in IndexCursor to prevent multiple table scans in FunctionIndex

上级 8fcd494b
......@@ -120,6 +120,10 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
return false;
}
@Override
public boolean isFindSlow() {
return false;
}
@Override
public Cursor find(TableFilter filter, SearchRow first, SearchRow last) {
......
......@@ -44,6 +44,11 @@ public class FunctionIndex extends BaseIndex {
throw DbException.getUnsupportedException("ALIAS");
}
@Override
public boolean isFindSlow() {
return true;
}
@Override
public Cursor find(Session session, SearchRow first, SearchRow last) {
if (functionTable.isBufferResultSetToLocalTemp()) {
......
......@@ -51,6 +51,15 @@ public interface Index extends SchemaObject {
*/
void remove(Session session, Row row);
/**
* Returns {@code true} if {@code find()} implementation performs scan over all
* index, {@code false} if {@code find()} performs the fast lookup.
*
* @return {@code true} if {@code find()} implementation performs scan over all
* index, {@code false} if {@code find()} performs the fast lookup
*/
boolean isFindSlow();
/**
* Find a row or a list of rows and create a cursor to iterate over the
* result.
......
......@@ -89,6 +89,9 @@ public class IndexCursor implements Cursor {
alwaysFalse = true;
break;
}
if (index.isFindSlow()) {
continue;
}
Column column = condition.getColumn();
if (condition.getCompareType() == Comparison.IN_LIST) {
if (start == null && end == null) {
......
......@@ -72,6 +72,11 @@ public class MultiVersionIndex implements Index {
}
}
@Override
public boolean isFindSlow() {
return base.isFindSlow();
}
@Override
public Cursor find(TableFilter filter, SearchRow first, SearchRow last) {
synchronized (sync) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论