Unverified 提交 d54db840 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1159 from katzyn/ResultTempTable

Do not create additional indexes in copies of ResultTempTable
......@@ -71,7 +71,7 @@ public class ResultTempTable implements ResultExternal {
data.session = session;
table = schema.createTable(data);
if (sort != null || distinct) {
createIndex();
getIndex();
}
parent = null;
}
......@@ -82,14 +82,19 @@ public class ResultTempTable implements ResultExternal {
this.distinct = parent.distinct;
this.session = parent.session;
this.table = parent.table;
this.index = parent.index;
this.rowCount = parent.rowCount;
this.sort = parent.sort;
this.containsLob = parent.containsLob;
reset();
}
private void createIndex() {
private Index getIndex() {
if (parent != null) {
return parent.getIndex();
}
if (index != null) {
return index;
}
IndexColumn[] indexCols;
if (sort != null) {
int[] colIndex = sort.getQueryColumnIndexes();
......@@ -128,7 +133,7 @@ public class ResultTempTable implements ResultExternal {
table, Constants.PREFIX_INDEX);
int indexId = session.getDatabase().allocateObjectId();
IndexType indexType = IndexType.createNonUnique(true);
index = table.addIndex(session, indexName, indexId, indexCols,
return index = table.addIndex(session, indexName, indexId, indexCols,
indexType, true, null);
}
......@@ -274,7 +279,7 @@ public class ResultTempTable implements ResultExternal {
if (resultCursor == null) {
Index idx;
if (distinct || sort != null) {
idx = index;
idx = getIndex();
} else {
idx = table.getScanIndex(session);
}
......@@ -304,12 +309,7 @@ public class ResultTempTable implements ResultExternal {
}
private Cursor find(Row row) {
if (index == null) {
// for the case "in(select ...)", the query might
// use an optimization and not create the index
// up front
createIndex();
}
Index index = getIndex();
Cursor cursor = index.find(session, row, row);
while (cursor.next()) {
SearchRow found = cursor.getSearchRow();
......
......@@ -18,7 +18,6 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.test.db.Db;
import org.h2.test.db.Db.Prepared;
import org.h2.util.Utils;
/**
* This test executes random SQL statements to test if optimizations are working
......@@ -117,18 +116,6 @@ public class TestFuzzOptimizations extends TestBase {
}
executeAndCompare(condition, params, message);
}
if (!config.mvStore && config.travis) {
/*
* Travis tests have problems with automatic garbage collection, so request a GC
* explicitly and print its results.
*/
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
println((Utils.getMemoryUsed() >> 10) + " MiB used");
}
}
executeAndCompare("a >=0 and b in(?, 2) and a in(1, ?, null)", Arrays.asList("10", "2"),
"testIn() seed=-6191135606105920350L");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论