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

Remove unused code.

上级 034866a0
......@@ -517,6 +517,19 @@ but not range scan (<code>WHERE ID &lt; ?</code>). To use hash indexes, use HASH
<code>CREATE TABLE ...(ID INT PRIMARY KEY HASH,...)</code>.
</p>
<h3>Use Prepared Statements</h3>
<p>
If possible, use prepared statements with parameters.
Avoid generating SQL statements with a variable size IN(...) list.
Instead, use arrays as in the following example:
</p>
<pre>
PreparedStatement prep = conn.prepareStatement(
"SELECT * FROM TABLE(X INT=?) T INNER JOIN TEST ON T.X=TEST.ID");
prep.setObject(1, new Object[] { "1", "2" });
ResultSet rs = prep.executeQuery();
</pre>
<h3>Optimization Examples</h3>
<p>
See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries
......
......@@ -8078,78 +8078,84 @@ In-memory indexes are automatically used for in-memory databases, but can also b
In-memory hash indexes are backed by a hash table and are usually faster than regular indexes. However, hash indexes only supports direct lookup (<code>WHERE ID = ?</code>) but not range scan (<code>WHERE ID &lt; ?</code>). To use hash indexes, use HASH as in: <code>CREATE UNIQUE HASH INDEX</code> and <code>CREATE TABLE ...(ID INT PRIMARY KEY HASH,...)</code>.
@performance_1429_h3
Optimization Examples
Use Prepared Statements
@performance_1430_p
See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries that benefit from special optimizations built into the database.
If possible, use prepared statements with parameters. Avoid generating SQL statements with a variable size IN(...) list. Instead, use arrays as in the following example:
@performance_1431_h3
Cache Size and Type
Optimization Examples
@performance_1432_p
By default the cache size of H2 is quite small. Consider using a larger cache size, or enable the second level soft reference cache. See also <a href="features.html#cache_settings">Cache Settings</a>.
See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries that benefit from special optimizations built into the database.
@performance_1433_h3
Data Types
Cache Size and Type
@performance_1434_p
By default the cache size of H2 is quite small. Consider using a larger cache size, or enable the second level soft reference cache. See also <a href="features.html#cache_settings">Cache Settings</a>.
@performance_1435_h3
Data Types
@performance_1436_p
Each data type has different storage and performance characteristics:
@performance_1435_li
@performance_1437_li
The <code>DECIMAL/NUMERIC</code> type is slower and requires more storage than the <code>REAL</code> and <code>DOUBLE</code> types.
@performance_1436_li
@performance_1438_li
Text types are slower to read, write, and compare than numeric types and generally require more storage.
@performance_1437_li
@performance_1439_li
See <a href="advanced.html#large_objects">Large Objects</a> for information on <code>BINARY</code> vs. <code>BLOB</code> and <code>VARCHAR</code> vs. <code>CLOB</code> performance.
@performance_1438_li
@performance_1440_li
Parsing and formatting takes longer for the <code>TIME</code>, <code>DATE</code>, and <code>TIMESTAMP</code> types than the numeric types.
@performance_1439_code
@performance_1441_code
SMALLINT/TINYINT/BOOLEAN
@performance_1440_li
@performance_1442_li
are not significantly smaller or faster to work with than <code>INTEGER</code> in most modes.
@performance_1441_h3
@performance_1443_h3
Sorted Insert Optimization
@performance_1442_p
@performance_1444_p
To reduce disk space usage and speed up table creation, an optimization for sorted inserts is available. When used, b-tree pages are split at the insertion point. To use this optimization, add <code>SORTED</code> before the <code>SELECT</code> statement:
@performance_1443_h2
@performance_1445_h2
Using the Built-In Profiler
@performance_1444_p
@performance_1446_p
A very simple Java profiler is built-in. To use it, use the following template:
@performance_1445_h2
@performance_1447_h2
Fast Database Import
@performance_1446_p
@performance_1448_p
To speed up large imports, consider using the following options temporarily:
@performance_1447_code
@performance_1449_code
SET CACHE_SIZE
@performance_1448_li
@performance_1450_li
(a large cache is faster)
@performance_1449_code
@performance_1451_code
SET LOCK_MODE 0
@performance_1450_li
@performance_1452_li
(disable locking)
@performance_1451_code
@performance_1453_code
SET UNDO_LOG 0
@performance_1452_li
@performance_1454_li
(disable the session undo log)
@performance_1453_p
@performance_1455_p
These options can be set in the database URL: <code>jdbc:h2:~/test;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0</code>. Most of those options are not recommended for regular use, that means you need to reset them after use.
@quickstart_1000_h1
......
......@@ -8078,78 +8078,84 @@ MySQL
# In-memory hash indexes are backed by a hash table and are usually faster than regular indexes. However, hash indexes only supports direct lookup (<code>WHERE ID = ?</code>) but not range scan (<code>WHERE ID &lt; ?</code>). To use hash indexes, use HASH as in: <code>CREATE UNIQUE HASH INDEX</code> and <code>CREATE TABLE ...(ID INT PRIMARY KEY HASH,...)</code>.
@performance_1429_h3
#Optimization Examples
#Use Prepared Statements
@performance_1430_p
# See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries that benefit from special optimizations built into the database.
# If possible, use prepared statements with parameters. Avoid generating SQL statements with a variable size IN(...) list. Instead, use arrays as in the following example:
@performance_1431_h3
#Cache Size and Type
#Optimization Examples
@performance_1432_p
# By default the cache size of H2 is quite small. Consider using a larger cache size, or enable the second level soft reference cache. See also <a href="features.html#cache_settings">Cache Settings</a>.
# See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries that benefit from special optimizations built into the database.
@performance_1433_h3
データ型
#Cache Size and Type #データ型
@performance_1434_p
# By default the cache size of H2 is quite small. Consider using a larger cache size, or enable the second level soft reference cache. See also <a href="features.html#cache_settings">Cache Settings</a>.
@performance_1435_h3
データ型
@performance_1436_p
# Each data type has different storage and performance characteristics:
@performance_1435_li
@performance_1437_li
#The <code>DECIMAL/NUMERIC</code> type is slower and requires more storage than the <code>REAL</code> and <code>DOUBLE</code> types.
@performance_1436_li
@performance_1438_li
#Text types are slower to read, write, and compare than numeric types and generally require more storage.
@performance_1437_li
@performance_1439_li
#See <a href="advanced.html#large_objects">Large Objects</a> for information on <code>BINARY</code> vs. <code>BLOB</code> and <code>VARCHAR</code> vs. <code>CLOB</code> performance.
@performance_1438_li
@performance_1440_li
#Parsing and formatting takes longer for the <code>TIME</code>, <code>DATE</code>, and <code>TIMESTAMP</code> types than the numeric types.
@performance_1439_code
@performance_1441_code
#SMALLINT/TINYINT/BOOLEAN
@performance_1440_li
@performance_1442_li
# are not significantly smaller or faster to work with than <code>INTEGER</code> in most modes.
@performance_1441_h3
@performance_1443_h3
#Sorted Insert Optimization
@performance_1442_p
@performance_1444_p
# To reduce disk space usage and speed up table creation, an optimization for sorted inserts is available. When used, b-tree pages are split at the insertion point. To use this optimization, add <code>SORTED</code> before the <code>SELECT</code> statement:
@performance_1443_h2
@performance_1445_h2
#Using the Built-In Profiler
@performance_1444_p
@performance_1446_p
# A very simple Java profiler is built-in. To use it, use the following template:
@performance_1445_h2
@performance_1447_h2
#Fast Database Import
@performance_1446_p
@performance_1448_p
# To speed up large imports, consider using the following options temporarily:
@performance_1447_code
@performance_1449_code
#SET CACHE_SIZE
@performance_1448_li
@performance_1450_li
# (a large cache is faster)
@performance_1449_code
@performance_1451_code
#SET LOCK_MODE 0
@performance_1450_li
@performance_1452_li
# (disable locking)
@performance_1451_code
@performance_1453_code
#SET UNDO_LOG 0
@performance_1452_li
@performance_1454_li
# (disable the session undo log)
@performance_1453_p
@performance_1455_p
# These options can be set in the database URL: <code>jdbc:h2:~/test;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0</code>. Most of those options are not recommended for regular use, that means you need to reset them after use.
@quickstart_1000_h1
......
......@@ -2691,31 +2691,33 @@ performance_1425_h3=In-Memory (Hash) Indexes
performance_1426_p=\ Using in-memory indexes, specially in-memory hash indexes, can speed up queries and data manipulation.
performance_1427_p=In-memory indexes are automatically used for in-memory databases, but can also be created for persistent databases using <code>CREATE MEMORY TABLE</code>. In many cases, the rows itself will also be kept in-memory. Please note this may cause memory problems for large tables.
performance_1428_p=\ In-memory hash indexes are backed by a hash table and are usually faster than regular indexes. However, hash indexes only supports direct lookup (<code>WHERE ID \= ?</code>) but not range scan (<code>WHERE ID &lt; ?</code>). To use hash indexes, use HASH as in\: <code>CREATE UNIQUE HASH INDEX</code> and <code>CREATE TABLE ...(ID INT PRIMARY KEY HASH,...)</code>.
performance_1429_h3=Optimization Examples
performance_1430_p=\ See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries that benefit from special optimizations built into the database.
performance_1431_h3=Cache Size and Type
performance_1432_p=\ By default the cache size of H2 is quite small. Consider using a larger cache size, or enable the second level soft reference cache. See also <a href\="features.html\#cache_settings">Cache Settings</a>.
performance_1433_h3=Data Types
performance_1434_p=\ Each data type has different storage and performance characteristics\:
performance_1435_li=The <code>DECIMAL/NUMERIC</code> type is slower and requires more storage than the <code>REAL</code> and <code>DOUBLE</code> types.
performance_1436_li=Text types are slower to read, write, and compare than numeric types and generally require more storage.
performance_1437_li=See <a href\="advanced.html\#large_objects">Large Objects</a> for information on <code>BINARY</code> vs. <code>BLOB</code> and <code>VARCHAR</code> vs. <code>CLOB</code> performance.
performance_1438_li=Parsing and formatting takes longer for the <code>TIME</code>, <code>DATE</code>, and <code>TIMESTAMP</code> types than the numeric types.
performance_1439_code=SMALLINT/TINYINT/BOOLEAN
performance_1440_li=\ are not significantly smaller or faster to work with than <code>INTEGER</code> in most modes.
performance_1441_h3=Sorted Insert Optimization
performance_1442_p=\ To reduce disk space usage and speed up table creation, an optimization for sorted inserts is available. When used, b-tree pages are split at the insertion point. To use this optimization, add <code>SORTED</code> before the <code>SELECT</code> statement\:
performance_1443_h2=Using the Built-In Profiler
performance_1444_p=\ A very simple Java profiler is built-in. To use it, use the following template\:
performance_1445_h2=Fast Database Import
performance_1446_p=\ To speed up large imports, consider using the following options temporarily\:
performance_1447_code=SET CACHE_SIZE
performance_1448_li=\ (a large cache is faster)
performance_1449_code=SET LOCK_MODE 0
performance_1450_li=\ (disable locking)
performance_1451_code=SET UNDO_LOG 0
performance_1452_li=\ (disable the session undo log)
performance_1453_p=\ These options can be set in the database URL\: <code>jdbc\:h2\:~/test;CACHE_SIZE\=65536;LOCK_MODE\=0;UNDO_LOG\=0</code>. Most of those options are not recommended for regular use, that means you need to reset them after use.
performance_1429_h3=Use Prepared Statements
performance_1430_p=\ If possible, use prepared statements with parameters. Avoid generating SQL statements with a variable size IN(...) list. Instead, use arrays as in the following example\:
performance_1431_h3=Optimization Examples
performance_1432_p=\ See <code>src/test/org/h2/samples/optimizations.sql</code> for a few examples of queries that benefit from special optimizations built into the database.
performance_1433_h3=Cache Size and Type
performance_1434_p=\ By default the cache size of H2 is quite small. Consider using a larger cache size, or enable the second level soft reference cache. See also <a href\="features.html\#cache_settings">Cache Settings</a>.
performance_1435_h3=Data Types
performance_1436_p=\ Each data type has different storage and performance characteristics\:
performance_1437_li=The <code>DECIMAL/NUMERIC</code> type is slower and requires more storage than the <code>REAL</code> and <code>DOUBLE</code> types.
performance_1438_li=Text types are slower to read, write, and compare than numeric types and generally require more storage.
performance_1439_li=See <a href\="advanced.html\#large_objects">Large Objects</a> for information on <code>BINARY</code> vs. <code>BLOB</code> and <code>VARCHAR</code> vs. <code>CLOB</code> performance.
performance_1440_li=Parsing and formatting takes longer for the <code>TIME</code>, <code>DATE</code>, and <code>TIMESTAMP</code> types than the numeric types.
performance_1441_code=SMALLINT/TINYINT/BOOLEAN
performance_1442_li=\ are not significantly smaller or faster to work with than <code>INTEGER</code> in most modes.
performance_1443_h3=Sorted Insert Optimization
performance_1444_p=\ To reduce disk space usage and speed up table creation, an optimization for sorted inserts is available. When used, b-tree pages are split at the insertion point. To use this optimization, add <code>SORTED</code> before the <code>SELECT</code> statement\:
performance_1445_h2=Using the Built-In Profiler
performance_1446_p=\ A very simple Java profiler is built-in. To use it, use the following template\:
performance_1447_h2=Fast Database Import
performance_1448_p=\ To speed up large imports, consider using the following options temporarily\:
performance_1449_code=SET CACHE_SIZE
performance_1450_li=\ (a large cache is faster)
performance_1451_code=SET LOCK_MODE 0
performance_1452_li=\ (disable locking)
performance_1453_code=SET UNDO_LOG 0
performance_1454_li=\ (disable the session undo log)
performance_1455_p=\ These options can be set in the database URL\: <code>jdbc\:h2\:~/test;CACHE_SIZE\=65536;LOCK_MODE\=0;UNDO_LOG\=0</code>. Most of those options are not recommended for regular use, that means you need to reset them after use.
quickstart_1000_h1=Quickstart
quickstart_1001_a=\ Embedding H2 in an Application
quickstart_1002_a=\ The H2 Console Application
......
......@@ -79,7 +79,8 @@ public class Mode {
public boolean squareBracketQuotedNames;
/**
* Support for the syntax [OFFSET .. ROW] [FETCH ... ONLY]
* Support for the syntax
* [OFFSET .. ROW|ROWS] [FETCH FIRST .. ROW|ROWS ONLY]
* as an alternative for LIMIT .. OFFSET.
*/
public boolean supportOffsetFetch;
......
......@@ -711,10 +711,6 @@ public class Session extends SessionWithState implements SessionFactory {
return firstUncommittedLog;
}
public int getFirstUncommittedPos() {
return firstUncommittedPos;
}
/**
* This method is called after the log file has committed this session.
*/
......
......@@ -86,6 +86,11 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
setTrace(factory.getTrace(), TraceObject.DATA_SOURCE, id);
}
/**
* Called when de-serializing the object.
*
* @param in the input stream
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
initFactory();
in.defaultReadObject();
......
......@@ -316,23 +316,4 @@ public class RunScript extends Tool {
}
}
/**
* If the statements as well as the results should be printed to the output.
*
* @param show true if yes
*/
public void setShowResults(boolean show) {
this.showResults = show;
}
/**
* If results of statements should be cross-checked with the expected
* output. The expected result is the next line(s) of the script, commented.
*
* @param check true if yes
*/
public void setCheckResults(boolean check) {
this.checkResults = check;
}
}
......@@ -7,7 +7,6 @@
package org.h2.util;
import org.h2.constant.SysProperties;
import org.h2.message.DbException;
/**
* An array with integer element.
......@@ -125,21 +124,6 @@ public class IntArray {
return size;
}
/**
* Remove the first element of this list that matches this value.
*
* @param value the value to be remove
*/
public void removeValue(int value) {
for (int i = 0; i < size; i++) {
if (data[i] == value) {
remove(i);
return;
}
}
DbException.throwInternalError();
}
/**
* Convert this list to an array. The target array must be big enough.
*
......
......@@ -291,26 +291,17 @@ java org.h2.test.TestAll timer
System.setProperty("h2.check2", "true");
/*
maybe remove ValueHashMap
test recovery of large pages and transaction log
test recovery with 'trace' mode (btree data)
test runscript with setCheckResults, execute, process, setShowResults
maybe remove ValueHashMap
rename Page* classes
move classes to the right packages
instead of AVL trees, use general balanced trees
test Row.getMemorySize
document in performance section:
PreparedStatement prep = conn.prepareStatement(
"select * from table(x int = ?) t inner join test on t.x = test.id");
prep.setObject(1, new Object[] { "1", "2" });
ResultSet rs = prep.executeQuery();
review package and class level javadocs
TestAll deleteIndex
document FETCH FIRST
power failure test: larger binaries and additional indexes
(with many columns).
......
......@@ -6,6 +6,8 @@
*/
package org.h2.test.jdbcx;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
......@@ -108,6 +110,12 @@ public class TestDataSource extends TestBase {
}
});
XAResource res = xaConn.getXAResource();
assertFalse(res.setTransactionTimeout(1));
assertEquals(0, res.getTransactionTimeout());
assertTrue(res.isSameRM(res));
assertFalse(res.isSameRM(null));
Connection conn = xaConn.getConnection();
Xid[] list = res.recover(XAResource.TMSTARTRSCAN);
assertEquals(0, list.length);
......@@ -120,6 +128,9 @@ public class TestDataSource extends TestBase {
private void testDataSource() throws SQLException {
deleteDb("dataSource");
JdbcDataSource ds = new JdbcDataSource();
PrintWriter p = new PrintWriter(new StringWriter());
ds.setLogWriter(p);
assertTrue(p == ds.getLogWriter());
ds.setURL(getURL("dataSource", true));
ds.setUser(getUser());
ds.setPassword(getPassword());
......
......@@ -51,7 +51,7 @@ public class TestIntArray extends TestBase {
for (int i = 0; i < 10000; i++) {
int idx = test.length == 0 ? 0 : random.nextInt(test.length);
int v = random.nextInt(100);
int op = random.nextInt(5);
int op = random.nextInt(4);
switch (op) {
case 0:
array.add(v);
......@@ -69,13 +69,6 @@ public class TestIntArray extends TestBase {
}
break;
case 3:
if (test.length > idx) {
v = test[idx];
array.removeValue(v);
test = removeValue(test, v);
}
break;
case 4:
assertEquals(test.length, array.size());
break;
default:
......@@ -116,13 +109,4 @@ public class TestIntArray extends TestBase {
return a2;
}
private int[] removeValue(int[] array, int value) {
for (int i = 0; i < array.length; i++) {
if (array[i] == value) {
return remove(array, i);
}
}
return array;
}
}
......@@ -545,12 +545,14 @@ public class TestTools extends TestBase {
String url = "jdbc:h2:" + baseDir + "/utils";
String user = "sa", password = "abc";
String fileName = baseDir + "/b2.sql";
DeleteDbFiles.main("-dir", baseDir, "-db", "utils", "-quiet");
Connection conn = DriverManager.getConnection(url, user, password);
conn.createStatement().execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
conn.createStatement().execute("INSERT INTO TEST VALUES(1, 'Hello')");
conn.close();
Script.main("-url", url, "-user", user, "-password", password, "-script", fileName, "-options",
"nodata", "compression", "lzf", "cipher", "xtea", "password", "'123'");
Script.main("-url", url, "-user", user, "-password", password, "-script", fileName + ".txt");
DeleteDbFiles.main("-dir", baseDir, "-db", "utils", "-quiet");
RunScript.main("-url", url, "-user", user, "-password", password, "-script", fileName,
"-options", "compression", "lzf", "cipher", "xtea", "password", "'123'");
......@@ -558,6 +560,14 @@ public class TestTools extends TestBase {
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
assertFalse(rs.next());
conn.close();
DeleteDbFiles.main("-dir", baseDir, "-db", "utils", "-quiet");
RunScript tool = new RunScript();
ByteArrayOutputStream buff = new ByteArrayOutputStream();
tool.setOut(new PrintStream(buff));
tool.runTool("-url", url, "-user", user, "-password", password, "-script", fileName + ".txt",
"-showResults");
assertTrue(buff.toString().indexOf("Hello") >= 0);
}
private void testBackupRestore() throws SQLException {
......
......@@ -634,4 +634,4 @@ profiles superinterfaces conventions brace indentations increments
explicitconstructorcall switchstatements members parens alignment declarations
jdt continuation codegen parenthesized tabulation ellipsis imple inits guardian
postfix iconified deiconified deactivated activated worker frequent utilities
workers appender recovers balanced
workers appender recovers balanced serializing
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论