You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2011/11/02 18:02:42 UTC

svn commit: r1196688 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c

Author: philip
Date: Wed Nov  2 17:02:42 2011
New Revision: 1196688

URL: http://svn.apache.org/viewvc?rev=1196688&view=rev
Log:
Revert the sorting part of r1196191, we can get the same performance from
SQL if we add an index.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_CREATE_DELETE_LIST): Add UNIQUE.
  (STMT_SELECT_DELETE_LIST): Restore ORDER BY.

* subversion/libsvn_wc/wc_db.c
  (do_delete_notify): Don't sort, retain cancellation after notification
   but reset statement before cancellation.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.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=1196688&r1=1196687&r2=1196688&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Nov  2 17:02:42 2011
@@ -1193,7 +1193,7 @@ DROP TABLE IF EXISTS delete_list;
 CREATE TEMPORARY TABLE delete_list (
 /* ### we should put the wc_id in here in case a delete spans multiple
    ### working copies. queries, etc will need to be adjusted.  */
-   local_relpath TEXT PRIMARY KEY NOT NULL
+   local_relpath TEXT PRIMARY KEY NOT NULL UNIQUE
    )
 
 /* This matches the selection in STMT_INSERT_DELETE_FROM_NODE_RECURSIVE */
@@ -1208,6 +1208,7 @@ WHERE wc_id = ?1
 
 -- STMT_SELECT_DELETE_LIST
 SELECT local_relpath FROM delete_list
+ORDER BY local_relpath
 
 -- STMT_FINALIZE_DELETE
 DROP TABLE IF EXISTS delete_list

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1196688&r1=1196687&r2=1196688&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Nov  2 17:02:42 2011
@@ -32,7 +32,6 @@
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
 #include "svn_hash.h"
-#include "svn_sorts.h"
 #include "svn_wc.h"
 #include "svn_checksum.h"
 #include "svn_pools.h"
@@ -6560,64 +6559,36 @@ do_delete_notify(void *baton,
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
   apr_pool_t *iterpool;
-  apr_array_header_t *delete_list;
-  svn_boolean_t sorted;
-  int i;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_DELETE_LIST));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
 
-  /* Build a sorted list of deleted nodes. STMT_SELECT_DELETE_LIST
-   * doesn't sort because sorting in SQL is more expensive than in C. */
-  delete_list = apr_array_make(scratch_pool, 1, sizeof(const char *));
-  sorted = TRUE;
-  i = 0;
+  iterpool = svn_pool_create(scratch_pool);
   while (have_row)
     {
       const char *notify_relpath;
       const char *notify_abspath;
-      const char *prev_abspath;
+
+      svn_pool_clear(iterpool);
 
       notify_relpath = svn_sqlite__column_text(stmt, 0, NULL);
       notify_abspath = svn_dirent_join(wcroot->abspath,
                                        notify_relpath,
-                                       scratch_pool);
-      if (i == 0)
-        {
-          APR_ARRAY_PUSH(delete_list, const char *) = notify_abspath;
-          i++;
-          SVN_ERR(svn_sqlite__step(&have_row, stmt));
-          continue;
-        }
-
-      prev_abspath = APR_ARRAY_IDX(delete_list, i - 1, const char *);
-      if (sorted)
-        sorted = (svn_path_compare_paths(prev_abspath, notify_abspath) <= 0);
-      APR_ARRAY_PUSH(delete_list, const char *) = notify_abspath;
-      i++;
-      SVN_ERR(svn_sqlite__step(&have_row, stmt));
-    }
-
-  SVN_ERR(svn_sqlite__reset(stmt));
-
-  if (!sorted)
-    qsort(delete_list->elts, delete_list->nelts, delete_list->elt_size,
-          svn_sort_compare_paths);
+                                       iterpool);
 
-  iterpool = svn_pool_create(scratch_pool);
-  for (i = 0; i < delete_list->nelts; i++)
-    {
-      svn_pool_clear(iterpool);
       notify_func(notify_baton,
-                  svn_wc_create_notify(APR_ARRAY_IDX(delete_list, i,
-                                                     const char *),
+                  svn_wc_create_notify(notify_abspath,
                                        svn_wc_notify_delete,
                                        iterpool),
                   iterpool);
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
     }
   svn_pool_destroy(iterpool);
 
+  SVN_ERR(svn_sqlite__reset(stmt));
+
   /* We only allow cancellation after notification for all deleted nodes
    * has happened. The nodes are already deleted so we should notify for
    * all of them. */