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

Conditions on the "_rowid_" pseudo-column didn't use an index when using the MVStore.

上级 6a639782
......@@ -17,7 +17,10 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.
<ul><li>Conditions on the "_rowid_" pseudo-column didn't use an index
when using the MVStore.
</li><li>Fixed documentation that "offset" and "fetch" are also keywords since version 1.4.x.
</li><li>The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.
</li><li>Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in
other JDBC classes.
</li><li>Issue 572: MySQL compatibility for "order by" in update statements.
......@@ -159,7 +162,7 @@ Change Log
</li><li>Implicit relative paths are disabled (system property "h2.implicitRelativePath"),
so that the database URL jdbc:h2:test now needs to be written as jdbc:h2:./test.
</li><li>"select ... fetch first 1 row only" is supported with the regular mode.
This was disabled so far because "fetch" is now a keyword.
This was disabled so far because "fetch" and "offset" are now keywords.
See also Mode.supportOffsetFetch.
</li><li>Byte arrays are now sorted in unsigned mode
(x'99' is larger than x'09').
......
......@@ -174,22 +174,26 @@ public class MVPrimaryIndex extends BaseIndex {
@Override
public Cursor find(Session session, SearchRow first, SearchRow last) {
ValueLong min, max;
if (first == null || mainIndexColumn < 0) {
if (first == null) {
min = MIN;
} else if (mainIndexColumn < 0) {
min = ValueLong.get(first.getKey());
} else {
ValueLong v = (ValueLong) first.getValue(mainIndexColumn);
if (v == null) {
min = ZERO;
min = ValueLong.get(first.getKey());
} else {
min = v;
}
}
if (last == null || mainIndexColumn < 0) {
if (last == null) {
max = MAX;
} else if (mainIndexColumn < 0) {
max = ValueLong.get(last.getKey());
} else {
ValueLong v = (ValueLong) last.getValue(mainIndexColumn);
if (v == null) {
max = MAX;
max = ValueLong.get(last.getKey());
} else {
max = v;
}
......
......@@ -41,6 +41,7 @@ public class TestOptimizations extends TestBase {
@Override
public void test() throws Exception {
deleteDb("optimizations");
testFastRowIdCondition();
testExplainRoundTrip();
testOrderByExpression();
testGroupSubquery();
......@@ -79,6 +80,18 @@ public class TestOptimizations extends TestBase {
deleteDb("optimizations");
}
private void testFastRowIdCondition() throws Exception {
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
stat.executeUpdate("create table many(id int) " +
"as select x from system_range(1, 10000)");
ResultSet rs = stat.executeQuery("explain analyze select * from many " +
"where _rowid_ = 400");
rs.next();
assertContains(rs.getString(1), "/* scanCount: 2 */");
conn.close();
}
private void testExplainRoundTrip() throws Exception {
Connection conn = getConnection("optimizations");
assertExplainRoundTrip(conn,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论