提交 5c5fde9e authored 作者: Noel Grandin's avatar Noel Grandin

Performance improvement for metadata queries that join against the COLUMNS metadata table.

上级 8273fd69
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Performance improvement for metadata queries that join against the COLUMNS metadata table.
</li>
<li>An ArrayIndexOutOfBoundsException was thrown in some cases
when opening an old version 1.3 database, or an 1.4 database with
both "mv_store=false" and the system property "h2.storeLocalTime" set to false.
......
......@@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import org.h2.command.Command;
import org.h2.constraint.Constraint;
import org.h2.constraint.ConstraintCheck;
......@@ -128,7 +127,7 @@ public class MetaTable extends Table {
this.type = type;
Column[] cols;
String indexColumnName = null;
switch (type) {
switch(type) {
case TABLES:
setObjectName("TABLES");
cols = createColumns(
......@@ -815,7 +814,16 @@ public class MetaTable extends Table {
break;
}
case INDEXES: {
for (Table table : getAllTables(session)) {
// reduce the number of tables to scan - makes some metadata queries
// 10x faster
final ArrayList<Table> tablesToList;
if (indexFrom != null && indexTo != null && indexFrom.equals(indexTo)) {
String tableName = identifier(indexFrom.getString());
tablesToList = getTablesByName(session, tableName);
} else {
tablesToList = getAllTables(session);
}
for (Table table : tablesToList) {
String tableName = identifier(table.getName());
if (!checkIndex(session, tableName, indexFrom, indexTo)) {
continue;
......@@ -1854,7 +1862,7 @@ public class MetaTable extends Table {
}
private static int getRefAction(int action) {
switch (action) {
switch(action) {
case ConstraintReferential.CASCADE:
return DatabaseMetaData.importedKeyCascade;
case ConstraintReferential.RESTRICT:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论