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

MVStore table engine (reduced memory usage and improved performance)

上级 47da2c44
...@@ -18,7 +18,8 @@ Change Log ...@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>The optimization for IN(...) queries combined with OR could result <ul><li>The auto-analyze feature now only reads 1000 rows per table instead of 10000.
</li><li>The optimization for IN(...) queries combined with OR could result
in a strange exception of the type "column x must be included in the group by list". in a strange exception of the type "column x must be included in the group by list".
</li><li>Issue 454: Use Charset for type-safety. </li><li>Issue 454: Use Charset for type-safety.
</li><li>Queries with both LIMIT and OFFSET could throw an IllegalArgumentException. </li><li>Queries with both LIMIT and OFFSET could throw an IllegalArgumentException.
......
...@@ -103,7 +103,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -103,7 +103,7 @@ public class MVPrimaryIndex extends BaseIndex {
row.setKey(++lastKey); row.setKey(++lastKey);
} }
} else { } else {
Long c = row.getValue(mainIndexColumn).getLong(); long c = row.getValue(mainIndexColumn).getLong();
row.setKey(c); row.setKey(c);
} }
......
...@@ -554,7 +554,7 @@ public class MVTable extends TableBase { ...@@ -554,7 +554,7 @@ public class MVTable extends TableBase {
if (n > 0) { if (n > 0) {
nextAnalyze = n; nextAnalyze = n;
} }
int rows = session.getDatabase().getSettings().analyzeSample; int rows = session.getDatabase().getSettings().analyzeSample / 10;
Analyze.analyzeTable(session, this, rows, false); Analyze.analyzeTable(session, this, rows, false);
} }
......
...@@ -15,10 +15,11 @@ public interface DataType { ...@@ -15,10 +15,11 @@ public interface DataType {
/** /**
* Compare two keys. * Compare two keys.
* *
* @param a the first key * @param a the first key
* @param b the second key * @param b the second key
* @return -1 if the first key is smaller, 1 if larger, and 0 if equal * @return -1 if the first key is smaller, 1 if larger, and 0 if equal
* @throws UnsupportedOperationException if the type is not orderable
*/ */
int compare(Object a, Object b); int compare(Object a, Object b);
......
...@@ -401,7 +401,7 @@ public class RegularTable extends TableBase { ...@@ -401,7 +401,7 @@ public class RegularTable extends TableBase {
if (n > 0) { if (n > 0) {
nextAnalyze = n; nextAnalyze = n;
} }
int rows = session.getDatabase().getSettings().analyzeSample; int rows = session.getDatabase().getSettings().analyzeSample / 10;
Analyze.analyzeTable(session, this, rows, false); Analyze.analyzeTable(session, this, rows, false);
} }
......
...@@ -8,7 +8,6 @@ package org.h2.test.store; ...@@ -8,7 +8,6 @@ package org.h2.test.store;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
...@@ -16,12 +15,12 @@ import java.sql.PreparedStatement; ...@@ -16,12 +15,12 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.mvstore.db.MVTableEngine; import org.h2.mvstore.db.MVTableEngine;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.Profiler;
import org.h2.util.Task; import org.h2.util.Task;
/** /**
...@@ -39,7 +38,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -39,7 +38,7 @@ public class TestMVTableEngine extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
// testSpeed(); // testSpeed();
testReopen(); testReopen();
testBlob(); testBlob();
testExclusiveLock(); testExclusiveLock();
...@@ -95,32 +94,21 @@ int tes; ...@@ -95,32 +94,21 @@ int tes;
// -mx4g // -mx4g
// fast size // fast size
// 10000 / 8000
// 1278 mvstore;LOCK_MODE=0 before
// 1524 mvstore;LOCK_MODE=0 after
// 790 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 834 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
// 1000 / 80000
// 1753 mvstore;LOCK_MODE=0 before
// 1998 mvstore;LOCK_MODE=0 after
// 810 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 818 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
// 100 / 800000
// 2270 mvstore;LOCK_MODE=0 before
// 2841 mvstore;LOCK_MODE=0 after
// 2107 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 2116 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
// 10 / 800000 // 10 / 800000
// 1312 mvstore;LOCK_MODE=0 before // 1265 mvstore;LOCK_MODE=0 before
// 1500 mvstore;LOCK_MODE=0 after // 1434 mvstore;LOCK_MODE=0 after
// 1541 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before // 1126 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 before
// 1551 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after // 1136 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 after
prep.setString(2, new String(new char[100]).replace((char) 0, 'x')); // 100 / 800000
for (int i = 0; i < 200000; i++) { // 2010 mvstore;LOCK_MODE=0 before
// 2261 mvstore;LOCK_MODE=0 after
// 1536 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 before
// 1546 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 after
prep.setString(2, new String(new char[10]).replace((char) 0, 'x'));
// for (int i = 0; i < 20000; i++) {
for (int i = 0; i < 800000; i++) {
prep.setInt(1, i); prep.setInt(1, i);
prep.execute(); prep.execute();
......
...@@ -40,7 +40,6 @@ public class TestTransactionStore extends TestBase { ...@@ -40,7 +40,6 @@ public class TestTransactionStore extends TestBase {
public void test() throws Exception { public void test() throws Exception {
FileUtils.createDirectories(getBaseDir()); FileUtils.createDirectories(getBaseDir());
testKeyIterator(); testKeyIterator();
testMultiStatement(); testMultiStatement();
testTwoPhaseCommit(); testTwoPhaseCommit();
...@@ -205,7 +204,7 @@ public class TestTransactionStore extends TestBase { ...@@ -205,7 +204,7 @@ public class TestTransactionStore extends TestBase {
list = ts.getOpenTransactions(); list = ts.getOpenTransactions();
assertEquals(1, list.size()); assertEquals(1, list.size());
txOld = list.get(0); txOld = list.get(0);
assertTrue(tx == txOld); assertTrue(tx.getId() == txOld.getId());
s.commit(); s.commit();
ts.close(); ts.close();
s.close(); s.close();
...@@ -233,7 +232,7 @@ public class TestTransactionStore extends TestBase { ...@@ -233,7 +232,7 @@ public class TestTransactionStore extends TestBase {
tx = ts.begin(); tx = ts.begin();
m = tx.openMap("test"); m = tx.openMap("test");
// TransactionStore was not closed, so we lost some ids // TransactionStore was not closed, so we lost some ids
assertEquals(33, tx.getId()); assertEquals(65, tx.getId());
list = ts.getOpenTransactions(); list = ts.getOpenTransactions();
assertEquals(2, list.size()); assertEquals(2, list.size());
txOld = list.get(1); txOld = list.get(1);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论