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

New database setting OPTIMIZE_IN_SELECT (enabled by default for version 1.3.x).…

New database setting OPTIMIZE_IN_SELECT (enabled by default for version 1.3.x). If enabled, IN(SELECT...) conditions are faster if there are many rows in the table or subquery.
上级 c1dba0ba
......@@ -60,7 +60,11 @@ public class ConditionInSelect extends Condition {
if (all && rows.getRowCount() > 1) {
return ValueBoolean.get(false);
}
l = l.convertTo(rows.getColumnType(0));
int dataType = rows.getColumnType(0);
if (dataType == Value.NULL) {
return ValueBoolean.get(false);
}
l = l.convertTo(dataType);
if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.get(true);
}
......
......@@ -183,7 +183,7 @@ public class TestFuzzOptimizations extends TestBase {
"IN(SELECT " + value + " FROM TEST I WHERE I." + compare + "=?) ORDER BY 1, 2";
List<Map<String, Object>> a = db.prepare(sql1).set(x).query();
List<Map<String, Object>> b = db.prepare(sql2).set(x).query();
assertTrue("seed: " + seed, a.equals(b));
assertTrue("seed: " + seed + " sql: " + sql1 + " a: " + a + " b: " + b, a.equals(b));
}
db.execute("DROP TABLE TEST");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论