Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-11-04 07:01:13 -0500
committerEike Stepper2008-11-04 07:01:13 -0500
commit98df5795b4ba6ac478e4a283fabeb6a3d04b374d (patch)
tree7e93d023ce6e8fea31c4b9479040527ed460e1ae
parent29d2ec870a4666f4ddfba4bcd0727aa60953eafc (diff)
downloadcdo-98df5795b4ba6ac478e4a283fabeb6a3d04b374d.tar.gz
cdo-98df5795b4ba6ac478e4a283fabeb6a3d04b374d.tar.xz
cdo-98df5795b4ba6ac478e4a283fabeb6a3d04b374d.zip
[250411] [DB] Create DB indexes for mapped tables
https://bugs.eclipse.org/bugs/show_bug.cgi?id=250411
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java11
3 files changed, 23 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
index 3403b023d7..b4a9fb317d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
@@ -81,6 +81,9 @@ public class CDODBSchema extends DBSchema
public static final IDBIndex INDEX_PACKAGES_URI = //
PACKAGES.addIndex(IDBIndex.Type.UNIQUE, PACKAGES_URI);
+ public static final IDBIndex INDEX_PACKAGES_PARENT = //
+ PACKAGES.addIndex(IDBIndex.Type.NON_UNIQUE, PACKAGES_PARENT);
+
/**
* DBTable cdo_classes
*/
@@ -104,6 +107,9 @@ public class CDODBSchema extends DBSchema
public static final IDBIndex INDEX_CLASSES_PK = //
CLASSES.addIndex(IDBIndex.Type.PRIMARY_KEY, CLASSES_ID);
+ public static final IDBIndex INDEX_CLASSES_PACKAGE = //
+ CLASSES.addIndex(IDBIndex.Type.NON_UNIQUE, CLASSES_PACKAGE);
+
/**
* DBTable cdo_supertypes
*/
@@ -159,6 +165,9 @@ public class CDODBSchema extends DBSchema
public static final IDBIndex INDEX_FEATURES_PK = //
FEATURES.addIndex(IDBIndex.Type.PRIMARY_KEY, FEATURES_ID);
+ public static final IDBIndex INDEX_FEATURES_CLASS = //
+ FEATURES.addIndex(IDBIndex.Type.NON_UNIQUE, FEATURES_CLASS);
+
/**
* Name of object table
*/
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index c079172f37..65ae811a0b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -30,6 +30,7 @@ import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -71,6 +72,7 @@ public abstract class ClassMapping implements IClassMapping
String tableName = mappingStrategy.getTableName(cdoClass);
table = addTable(tableName);
initTable(table, hasFullRevisionInfo());
+
if (features != null)
{
attributeMappings = createAttributeMappings(features);
@@ -129,16 +131,18 @@ public abstract class ClassMapping implements IClassMapping
protected void initTable(IDBTable table, boolean full)
{
- table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT, true);
+ IDBField idField = table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT, true);
table.addField(CDODBSchema.ATTRIBUTES_VERSION, DBType.INTEGER, true);
if (full)
{
table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.INTEGER, true);
table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT, true);
- table.addField(CDODBSchema.ATTRIBUTES_REVISED, DBType.BIGINT, true);
+ IDBField revisedField = table.addField(CDODBSchema.ATTRIBUTES_REVISED, DBType.BIGINT, true);
table.addField(CDODBSchema.ATTRIBUTES_RESOURCE, DBType.BIGINT, true);
table.addField(CDODBSchema.ATTRIBUTES_CONTAINER, DBType.BIGINT, true);
table.addField(CDODBSchema.ATTRIBUTES_FEATURE, DBType.INTEGER, true);
+
+ table.addIndex(IDBIndex.Type.NON_UNIQUE, idField, revisedField);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
index cafe2956d5..f420dc6e5f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
@@ -27,7 +27,9 @@ import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.db.ddl.IDBIndex.Type;
import org.eclipse.net4j.util.collection.MoveableList;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -297,10 +299,13 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
table.addField(CDODBSchema.REFERENCES_FEATURE, DBType.INTEGER);
}
- table.addField(CDODBSchema.REFERENCES_SOURCE, DBType.BIGINT);
- table.addField(CDODBSchema.REFERENCES_VERSION, DBType.INTEGER);
- table.addField(CDODBSchema.REFERENCES_IDX, DBType.INTEGER);
+ IDBField sourceField = table.addField(CDODBSchema.REFERENCES_SOURCE, DBType.BIGINT);
+ IDBField versionField = table.addField(CDODBSchema.REFERENCES_VERSION, DBType.INTEGER);
+ IDBField idxField = table.addField(CDODBSchema.REFERENCES_IDX, DBType.INTEGER);
table.addField(CDODBSchema.REFERENCES_TARGET, DBType.BIGINT);
+
+ table.addIndex(Type.NON_UNIQUE, sourceField, versionField);
+ table.addIndex(Type.NON_UNIQUE, idxField);
return table;
}

Back to the top