[exo-jcr-commits] exo-jcr SVN: r2045 - in jcr/trunk/exo.jcr.component.core/src/main: java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 9 11:45:52 EST 2010


Author: nfilotto
Date: 2010-03-09 11:45:51 -0500 (Tue, 09 Mar 2010)
New Revision: 2045

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql-utf8.sql
   jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql.sql
   jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql-utf8.sql
   jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql.sql
Log:
EXOJCR-519: A proposal to improve performances on mysql, the idea was to ensure that no explain plans contain "Using filesort" and/or "Using temporary" since it is not recommended according to http://dev.mysql.com/doc/refman/5.1/en/using-explain.html
To remove them, I had to add indexes and remove some order by clauses to replace them by a local sort

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java	2010-03-09 16:45:51 UTC (rev 2045)
@@ -45,10 +45,15 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
 import java.util.StringTokenizer;
+import java.util.TreeSet;
 
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.RepositoryException;
@@ -93,6 +98,18 @@
    protected String FIND_ITEM_QPATH_BY_ID_CQ;
 
    /**
+    * The comparator used to sort the value data
+    */
+   private static Comparator<ValueData> COMPARATOR_VALUE_DATA = new Comparator<ValueData>()
+   {
+
+      public int compare(ValueData vd1, ValueData vd2)
+      {
+         return vd1.getOrderNumber() - vd2.getOrderNumber();
+      }      
+   };
+   
+   /**
     * Class needed to store node details (property also) since result set is not sorted in valid way. 
     */
    private static class TempNodeData
@@ -109,7 +126,7 @@
 
       int cnordernumb;
 
-      Map<String, List<byte[]>> properties = new HashMap<String, List<byte[]>>();
+      Map<String, SortedSet<TempPropertyData>> properties = new HashMap<String, SortedSet<TempPropertyData>>();
 
       public TempNodeData(ResultSet item) throws SQLException
       {
@@ -121,7 +138,27 @@
          cnordernumb = item.getInt(COLUMN_NORDERNUM);
       }
    }
+   
+   /**
+    * store temporary property data to allow to sort it manually
+    */
+   private static class TempPropertyData implements Comparable<TempPropertyData>
+   {
+      int orderNum;
+      byte[] data;
+      
+      public TempPropertyData(ResultSet item) throws SQLException
+      {
+         orderNum = item.getInt(COLUMN_VORDERNUM);
+         data = item.getBytes(COLUMN_VDATA);
+      }
 
+      public int compareTo(TempPropertyData o)
+      {
+         return orderNum - o.orderNum;
+      }
+   }
+
    /**
      * JDBCStorageConnection constructor.
      * 
@@ -172,15 +209,15 @@
                childNodes.add(nodeData);
                data = new TempNodeData(resultSet);
             }
-            Map<String, List<byte[]>> properties = data.properties;
+            Map<String, SortedSet<TempPropertyData>> properties = data.properties;
             String key = resultSet.getString("PROP_NAME");
-            List<byte[]> values = properties.get(key);
+            SortedSet<TempPropertyData> values = properties.get(key);
             if (values == null)
             {
-               values = new ArrayList<byte[]>();
+               values = new TreeSet<TempPropertyData>();
                properties.put(key, values);
             }
-            values.add(resultSet.getBytes(COLUMN_VDATA));
+            values.add(new TempPropertyData(resultSet));
          }
          if (data != null)
          {
@@ -275,7 +312,9 @@
                   isNotLast = resultSet.next();
                }
                while (isNotLast && resultSet.getString(COLUMN_ID).equals(cid));
-
+               
+               // To avoid using a temporary table, we sort the values manually
+               Collections.sort(data, COMPARATOR_VALUE_DATA);
                //create property
                PersistedPropertyData pdata =
                   new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued,
@@ -405,7 +444,7 @@
                copies++;
                dublicatedProps.put(identifier, copies);
             }
-            else if (values.size() <= valueOrderNum)
+            else if (values.size() == valueOrderNum)
             {
                // read value and put into values buffer
                final String storageId = resultSet.getString(COLUMN_VSTORAGE_DESC);
@@ -423,6 +462,7 @@
 
             PersistedPropertyData prop = propertyBuffer.get(id);
             List<ValueData> values = valuesBuffer.get(id);
+            Collections.sort(values, COMPARATOR_VALUE_DATA);
             int count = dublicatedProps.get(id).intValue();
 
             for (int i = 0; i < count; i++)
@@ -466,17 +506,17 @@
     * @throws SQLException
     * @throws IllegalACLException
     */
-   protected List<AccessControlEntry> readACLPermisions(String cid, Map<String, List<byte[]>> properties)
+   protected List<AccessControlEntry> readACLPermisions(String cid, Map<String, SortedSet<TempPropertyData>> properties)
       throws SQLException, IllegalACLException
    {
       List<AccessControlEntry> naPermissions = new ArrayList<AccessControlEntry>();
-      List<byte[]> permValues = properties.get(Constants.EXO_PERMISSIONS.getAsString());
+      Set<TempPropertyData> permValues = properties.get(Constants.EXO_PERMISSIONS.getAsString());
 
       if (permValues != null)
       {
-         for (byte[] value : permValues)
+         for (TempPropertyData value : permValues)
          {
-            StringTokenizer parser = new StringTokenizer(new String(value), AccessControlEntry.DELIMITER);
+            StringTokenizer parser = new StringTokenizer(new String(value.data), AccessControlEntry.DELIMITER);
             naPermissions.add(new AccessControlEntry(parser.nextToken(), parser.nextToken()));
          }
 
@@ -490,15 +530,15 @@
     * Read ACL owner.
     * 
     * @param cid - node id (used only in exception message)
-    * @param properties - Proeprty name and property values
+    * @param properties - Property name and property values
     * @return ACL owner
     * @throws IllegalACLException
     */
-   protected String readACLOwner(String cid, Map<String, List<byte[]>> properties) throws IllegalACLException
+   protected String readACLOwner(String cid, Map<String, SortedSet<TempPropertyData>> properties) throws IllegalACLException
    {
-      List<byte[]> ownerValues = properties.get(Constants.EXO_OWNER.getAsString());
+      SortedSet<TempPropertyData> ownerValues = properties.get(Constants.EXO_OWNER.getAsString());
       if (ownerValues != null)
-         return new String(ownerValues.get(0));
+         return new String(ownerValues.first().data);
       else
          throw new IllegalACLException("Property exo:owner is not found for node with id: " + getIdentifier(cid));
    }
@@ -510,17 +550,17 @@
       int cversion, int cnordernumb, AccessControlList parentACL) throws RepositoryException, SQLException
    {
       ResultSet ptProp = findNodeMainPropertiesByParentIdentifierCQ(cid);
-      Map<String, List<byte[]>> properties = new HashMap<String, List<byte[]>>();
+      Map<String, SortedSet<TempPropertyData>> properties = new HashMap<String, SortedSet<TempPropertyData>>();
       while (ptProp.next())
       {
          String key = ptProp.getString(COLUMN_NAME);
-         List<byte[]> values = properties.get(key);
+         SortedSet<TempPropertyData> values = properties.get(key);
          if (values == null)
          {
-            values = new ArrayList<byte[]>();
+            values = new TreeSet<TempPropertyData>();
             properties.put(key, values);
          }
-         values.add(ptProp.getBytes(COLUMN_VDATA));
+         values.add(new TempPropertyData(ptProp));
       }
 
       return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, properties, parentACL);
@@ -543,12 +583,12 @@
       return loadNodeRecord(parentPath, tempData.cname, tempData.cid, tempData.cpid, tempData.cindex,
          tempData.cversion, tempData.cnordernumb, tempData.properties, parentACL);
    }
-
+   
    /**
     * Create a new node from the given parameter.
     */
    private PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
-      int cversion, int cnordernumb, Map<String, List<byte[]>> properties, AccessControlList parentACL)
+      int cversion, int cnordernumb, Map<String, SortedSet<TempPropertyData>> properties, AccessControlList parentACL)
       throws RepositoryException, SQLException
    {
       try
@@ -580,27 +620,27 @@
          }
 
          // PRIMARY
-         List<byte[]> primaryType = properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
+         SortedSet<TempPropertyData> primaryType = properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
          if (primaryType == null || primaryType.isEmpty())
          {
             throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record not found. Node "
                + qpath.getAsString() + ", id " + cid + ", container " + this.containerName, null);
          }
 
-         byte[] data = primaryType.get(0);
+         byte[] data = primaryType.first().data;
          InternalQName ptName = InternalQName.parse(new String((data != null ? data : new byte[]{})));
 
          // MIXIN
          InternalQName[] mts;
          boolean owneable = false;
          boolean privilegeable = false;
-         List<byte[]> mixTypes = properties.get(Constants.JCR_MIXINTYPES.getAsString());
+         Set<TempPropertyData> mixTypes = properties.get(Constants.JCR_MIXINTYPES.getAsString());
          if (mixTypes != null)
          {
             List<InternalQName> mNames = new ArrayList<InternalQName>();
-            for (byte[] mxnb : mixTypes)
+            for (TempPropertyData mxnb : mixTypes)
             {
-               InternalQName mxn = InternalQName.parse(new String(mxnb));
+               InternalQName mxn = InternalQName.parse(new String(mxnb.data));
                mNames.add(mxn);
 
                if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java	2010-03-09 16:45:51 UTC (rev 2045)
@@ -191,7 +191,7 @@
       FIND_REFERENCE_PROPERTIES_CQ =
          "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
             + " from JCR_MREF R, JCR_MITEM P, JCR_MVALUE V"
-            + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by P.ID, V.ORDER_NUM";
+            + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by R.PROPERTY_ID";
 
       FIND_VALUES_BY_PROPERTYID =
          "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
@@ -206,12 +206,12 @@
          "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
             + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
             + " where I.PARENT_ID=? and I.I_CLASS=1 and (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
-            + " order by I.N_ORDER_NUM, I.ID, PROP_NAME DESC, V.ORDER_NUM";
+            + " order by I.N_ORDER_NUM, I.ID";
       
       FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
-         "select I.NAME, V.DATA"
+         "select I.NAME, V.DATA, V.ORDER_NUM"
             + " from JCR_MITEM I, JCR_MVALUE V"
-            + " where I.I_CLASS=2 and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+            + " where I.I_CLASS=2 and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID";
 
       FIND_ITEM_QPATH_BY_ID_CQ =
          "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
@@ -226,7 +226,7 @@
       FIND_PROPERTIES_BY_PARENTID_CQ =
          "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
             + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
-            + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.ID, V.ORDER_NUM";
+            + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.ID";
 
       INSERT_NODE =
          "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java	2010-03-09 16:45:51 UTC (rev 2045)
@@ -198,7 +198,7 @@
       FIND_REFERENCE_PROPERTIES_CQ =
          "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
             + " from JCR_SREF R, JCR_SITEM P, JCR_SVALUE V"
-            + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by P.ID, V.ORDER_NUM";
+            + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by R.PROPERTY_ID";
 
       FIND_VALUES_BY_PROPERTYID =
          "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
@@ -214,12 +214,12 @@
          "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
             + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
             + " where I.CONTAINER_NAME=? and I.PARENT_ID=? and I.I_CLASS=1 and (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
-            + " order by I.N_ORDER_NUM, I.ID, PROP_NAME DESC, V.ORDER_NUM";
+            + " order by I.N_ORDER_NUM, I.ID";
 
       FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
-         "select I.NAME, V.DATA"
+         "select I.NAME, V.DATA, V.ORDER_NUM"
             + " from JCR_SITEM I, JCR_SVALUE V"
-            + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+            + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID";
 
       FIND_ITEM_QPATH_BY_ID_CQ =
          "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
@@ -235,7 +235,7 @@
       FIND_PROPERTIES_BY_PARENTID_CQ =
          "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
             + " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
-            + " where I.I_CLASS=2 and CONTAINER_NAME=? and I.PARENT_ID=? order by I.ID, V.ORDER_NUM";
+            + " where I.I_CLASS=2 and CONTAINER_NAME=? and I.PARENT_ID=? order by I.ID";
 
       INSERT_NODE =
          "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"

Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql-utf8.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql-utf8.sql	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql-utf8.sql	2010-03-09 16:45:51 UTC (rev 2045)
@@ -18,6 +18,7 @@
 CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT ON JCR_MITEM(PARENT_ID, NAME(255), I_INDEX, I_CLASS, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT_NAME ON JCR_MITEM(I_CLASS, PARENT_ID, NAME(255), I_INDEX, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT_ID ON JCR_MITEM(I_CLASS, PARENT_ID, ID, VERSION DESC);
+CREATE INDEX JCR_IDX_MITEM_PARENT_N_ORDER_NUM ON JCR_MITEM(I_CLASS, PARENT_ID, N_ORDER_NUM, ID);
 CREATE TABLE JCR_MVALUE(
 	ID SERIAL NOT NULL, 
 	DATA LONGBLOB, 
@@ -28,6 +29,7 @@
 	CONSTRAINT JCR_FK_MVALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_MITEM(ID)
 );
 CREATE UNIQUE INDEX JCR_IDX_MVALUE_PROPERTY ON JCR_MVALUE(PROPERTY_ID, ORDER_NUM);
+CREATE INDEX JCR_IDX_MVALUE_STORAGE_DESC ON JCR_MVALUE(PROPERTY_ID, STORAGE_DESC);
 CREATE TABLE JCR_MREF(
   NODE_ID VARCHAR(56) NOT NULL, 
   PROPERTY_ID VARCHAR(56) NOT NULL,

Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql.sql	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.mysql.sql	2010-03-09 16:45:51 UTC (rev 2045)
@@ -18,6 +18,7 @@
 CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT ON JCR_MITEM(PARENT_ID, NAME, I_INDEX, I_CLASS, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT_NAME ON JCR_MITEM(I_CLASS, PARENT_ID, NAME, I_INDEX, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT_ID ON JCR_MITEM(I_CLASS, PARENT_ID, ID, VERSION DESC);
+CREATE INDEX JCR_IDX_MITEM_PARENT_N_ORDER_NUM ON JCR_MITEM(I_CLASS, PARENT_ID, N_ORDER_NUM, ID);
 CREATE TABLE JCR_MVALUE(
 	ID SERIAL NOT NULL, 
 	DATA LONGBLOB, 
@@ -28,6 +29,7 @@
 	CONSTRAINT JCR_FK_MVALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_MITEM(ID)
 );
 CREATE UNIQUE INDEX JCR_IDX_MVALUE_PROPERTY ON JCR_MVALUE(PROPERTY_ID, ORDER_NUM);
+CREATE INDEX JCR_IDX_MVALUE_STORAGE_DESC ON JCR_MVALUE(PROPERTY_ID, STORAGE_DESC);
 CREATE TABLE JCR_MREF(
   NODE_ID VARCHAR(96) NOT NULL, 
   PROPERTY_ID VARCHAR(96) NOT NULL,

Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql-utf8.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql-utf8.sql	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql-utf8.sql	2010-03-09 16:45:51 UTC (rev 2045)
@@ -19,6 +19,7 @@
 CREATE UNIQUE INDEX JCR_IDX_SITEM_PARENT ON JCR_SITEM(CONTAINER_NAME, PARENT_ID, NAME(255), I_INDEX, I_CLASS, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_SITEM_PARENT_NAME ON JCR_SITEM(I_CLASS, CONTAINER_NAME, PARENT_ID, NAME(255), I_INDEX, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_SITEM_PARENT_ID ON JCR_SITEM(I_CLASS, CONTAINER_NAME, PARENT_ID, ID, VERSION DESC);
+CREATE INDEX JCR_IDX_SITEM_PARENT_N_ORDER_NUM ON JCR_SITEM(I_CLASS, CONTAINER_NAME, PARENT_ID, N_ORDER_NUM, ID);
 CREATE TABLE JCR_SVALUE(
 	ID SERIAL NOT NULL, 
 	DATA LONGBLOB,
@@ -29,6 +30,7 @@
 	CONSTRAINT JCR_FK_SVALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_SITEM(ID)
 );
 CREATE UNIQUE INDEX JCR_IDX_SVALUE_PROPERTY ON JCR_SVALUE(PROPERTY_ID, ORDER_NUM);
+CREATE INDEX JCR_IDX_SVALUE_STORAGE_DESC ON JCR_SVALUE(PROPERTY_ID, STORAGE_DESC);
 CREATE TABLE JCR_SREF(
   NODE_ID VARCHAR(56) NOT NULL, 
   PROPERTY_ID VARCHAR(56) NOT NULL,

Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql.sql	2010-03-09 10:38:59 UTC (rev 2044)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.mysql.sql	2010-03-09 16:45:51 UTC (rev 2045)
@@ -19,6 +19,7 @@
 CREATE UNIQUE INDEX JCR_IDX_SITEM_PARENT ON JCR_SITEM(CONTAINER_NAME, PARENT_ID, NAME, I_INDEX, I_CLASS, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_SITEM_PARENT_NAME ON JCR_SITEM(I_CLASS, CONTAINER_NAME, PARENT_ID, NAME, I_INDEX, VERSION DESC);
 CREATE UNIQUE INDEX JCR_IDX_SITEM_PARENT_ID ON JCR_SITEM(I_CLASS, CONTAINER_NAME, PARENT_ID, ID, VERSION DESC);
+CREATE INDEX JCR_IDX_SITEM_PARENT_N_ORDER_NUM ON JCR_SITEM(I_CLASS, CONTAINER_NAME, PARENT_ID, N_ORDER_NUM, ID);
 CREATE TABLE JCR_SVALUE(
 	ID SERIAL NOT NULL, 
 	DATA LONGBLOB,
@@ -29,6 +30,7 @@
 	CONSTRAINT JCR_FK_SVALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_SITEM(ID)
 );
 CREATE UNIQUE INDEX JCR_IDX_SVALUE_PROPERTY ON JCR_SVALUE(PROPERTY_ID, ORDER_NUM);
+CREATE INDEX JCR_IDX_SVALUE_STORAGE_DESC ON JCR_SVALUE(PROPERTY_ID, STORAGE_DESC);
 CREATE TABLE JCR_SREF(
   NODE_ID VARCHAR(96) NOT NULL, 
   PROPERTY_ID VARCHAR(96) NOT NULL,



More information about the exo-jcr-commits mailing list