You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2012/05/23 12:53:26 UTC

svn commit: r1341826 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c tests/libsvn_wc/wc-queries-test.c

Author: rhuijben
Date: Wed May 23 10:53:25 2012
New Revision: 1341826

URL: http://svn.apache.org/viewvc?rev=1341826&view=rev
Log:
Make the recursive property retrieval functions in the wc_db api proportional
to the list of targets instead of to the total size of the working copy.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_CREATE_TARGETS_LIST): Add primary key, to give Sqlite a primary index.

  (STMT_CACHE_NODE_PROPS): Renamed to ...
  (STMT_CACHE_TARGET_PROPS): ... this. Join starting from the targets table
    to avoid a wc scan on the nodes table to check for each item if it is
    in the targets list. Integrate the STMT_CACHE_ACTUAL_PROPS statement
    as that gives us the final result in a single step.
  (STMT_CACHE_ACTUAL_PROPS): Remove statement.
    Folded into STMT_CACHE_TARGET_PROPS.

  (STMT_CACHE_NODE_PRISTINE_PROPS): Renamed to ...
  (STMT_CACHE_TARGET_PRISTINE_PROPS): ... this. Join starting with the targets
    table. Use a CASE to only fetch properties from below when we have a
    base-deleted node.

* subversion/libsvn_wc/wc_db.c
  (cache_props_recursive): Remove usage of STMT_CACHE_ACTUAL_PROPS.

* subversion/tests/libsvn_wc/wc-queries-test.c
  (slow_statements): Remove three more slow statements.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1341826&r1=1341825&r2=1341826&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed May 23 10:53:25 2012
@@ -467,7 +467,8 @@ CREATE TEMPORARY TABLE targets_list (
   wc_id  INTEGER NOT NULL,
   local_relpath TEXT NOT NULL,
   parent_relpath TEXT,
-  kind TEXT NOT NULL
+  kind TEXT NOT NULL,
+  PRIMARY KEY (wc_id, local_relpath)
   );
 CREATE INDEX targets_list_kind
   ON targets_list (kind)
@@ -1101,35 +1102,37 @@ CREATE TEMPORARY TABLE temp__node_props_
 CREATE UNIQUE INDEX temp__node_props_cache_unique
   ON temp__node_props_cache (local_relpath) */
 
--- STMT_CACHE_NODE_PROPS
+-- STMT_CACHE_TARGET_PROPS
 INSERT INTO temp__node_props_cache(local_relpath, kind, properties)
- SELECT local_relpath, kind, properties FROM nodes_current
-  WHERE wc_id = ?1
-    AND local_relpath IN (SELECT local_relpath FROM targets_list)
-    AND presence IN ('normal', 'incomplete')
+ SELECT n.local_relpath, n.kind,
+        IFNULL((SELECT properties FROM actual_node AS a
+                 WHERE a.wc_id = n.wc_id
+                   AND a.local_relpath = n.local_relpath),
+               n.properties)
+   FROM targets_list AS t
+   JOIN nodes_current AS n ON t.wc_id= n.wc_id
+                          AND t.local_relpath = n.local_relpath
+  WHERE t.wc_id = ?1
+    AND (presence='normal' OR presence='incomplete')
 
--- STMT_CACHE_ACTUAL_PROPS
-UPDATE temp__node_props_cache 
-   SET properties=
-        IFNULL((SELECT properties FROM actual_node a
-                 WHERE a.wc_id = ?1
-                   AND a.local_relpath = temp__node_props_cache.local_relpath),
-               properties)
-
--- STMT_CACHE_NODE_PRISTINE_PROPS
+-- STMT_CACHE_TARGET_PRISTINE_PROPS
 INSERT INTO temp__node_props_cache(local_relpath, kind, properties)
- SELECT local_relpath, kind, 
-        IFNULL((SELECT properties FROM nodes nn
-                 WHERE n.presence = 'base-deleted'
-                   AND nn.wc_id = n.wc_id
-                   AND nn.local_relpath = n.local_relpath
-                   AND nn.op_depth < n.op_depth
-                 ORDER BY op_depth DESC),
-               properties)
-  FROM nodes_current n
-  WHERE wc_id = ?1
-    AND local_relpath IN (SELECT local_relpath FROM targets_list)
-    AND presence IN ('normal', 'incomplete', 'base-deleted')
+ SELECT n.local_relpath, n.kind,
+        CASE n.presence
+          WHEN 'base-deleted'
+          THEN (SELECT properties FROM nodes AS p
+                 WHERE p.wc_id = n.wc_id
+                   AND p.local_relpath = n.local_relpath
+                   AND p.op_depth < n.op_depth
+                 ORDER BY p.op_depth DESC /* LIMIT 1 */)
+          ELSE properties END
+  FROM targets_list AS t
+  JOIN nodes_current AS n ON t.wc_id= n.wc_id
+                          AND t.local_relpath = n.local_relpath
+  WHERE t.wc_id = ?1
+    AND (presence = 'normal'
+         OR presence = 'incomplete'
+         OR presence = 'base-deleted')
 
 -- STMT_SELECT_RELEVANT_PROPS_FROM_CACHE
 SELECT local_relpath, properties FROM temp__node_props_cache

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1341826&r1=1341825&r2=1341826&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed May 23 10:53:25 2012
@@ -8232,26 +8232,14 @@ cache_props_recursive(void *cb_baton,
                                       STMT_CREATE_NODE_PROPS_CACHE));
 
   if (baton->pristine)
-    stmt_idx = STMT_CACHE_NODE_PRISTINE_PROPS;
+    stmt_idx = STMT_CACHE_TARGET_PRISTINE_PROPS;
   else
-    stmt_idx = STMT_CACHE_NODE_PROPS;
+    stmt_idx = STMT_CACHE_TARGET_PROPS;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, stmt_idx));
   SVN_ERR(svn_sqlite__bind_int64(stmt, 1, wcroot->wc_id));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
-  /* ACTUAL props aren't relevant in the pristine case. */
-  if (baton->pristine)
-    return SVN_NO_ERROR;
-
-  if (baton->cancel_func)
-    SVN_ERR(baton->cancel_func(baton->cancel_baton));
-
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                    STMT_CACHE_ACTUAL_PROPS));
-  SVN_ERR(svn_sqlite__bind_int64(stmt, 1, wcroot->wc_id));
-  SVN_ERR(svn_sqlite__step_done(stmt));
-
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c?rev=1341826&r1=1341825&r2=1341826&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c Wed May 23 10:53:25 2012
@@ -104,9 +104,6 @@ static const int slow_statements[] =
   STMT_HAS_ACTUAL_NODES_CONFLICTS,
 
   /* Join on targets table */
-  STMT_CACHE_NODE_PROPS,
-  STMT_CACHE_ACTUAL_PROPS,
-  STMT_CACHE_NODE_PRISTINE_PROPS,
   STMT_SELECT_RELEVANT_PROPS_FROM_CACHE,
   STMT_UPDATE_ACTUAL_CHANGELISTS,