Author: rhuijben
Date: Tue May 17 08:47:00 2011
New Revision: 1104056
URL: http://svn.apache.org/viewvc?rev=1104056&view=rev
Log:
Update the heaviest delete queries with the recent knowledge about how
like is used. Also add op_depth checks where we know the op_depth, to
remove subqueries.
* subversion/libsvn_wc/wc-queries.sql
(STMT_DELETE_NODES_RECURSIVE): Construct optimal query, fixing up for when
the query is used from revert.
(STMT_INSERT_DELETE_FROM_NODE_RECURSIVE): Construct path selection and apply
the known depth of the layer we are deleting instead of using a subquery
to determine that for every node.
(STMT_INSERT_DELETE_LIST): Construct path selection; limit the depth to the
valid range and only then use the subquery.
* subversion/libsvn_wc/wc_db.c
(op_revert_recursive_txn): Update caller.
(remove_node_txn): Update caller.
(op_delete_txn): Update caller. Determine the depth of what we are deleting.
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=1104056&r1=1104055&r2=1104056&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue May 17 08:47:00
2011
@@ -559,8 +559,11 @@ WHERE wc_id = ?1 AND local_relpath = ?2
-- STMT_DELETE_NODES_RECURSIVE
DELETE FROM nodes
-WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')
- AND op_depth >= ?4
+WHERE wc_id = ?1
+ AND (local_relpath = ?2
+ OR ?2 = ''
+ OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+ AND op_depth >= ?3
-- STMT_DELETE_ACTUAL_NODE
DELETE FROM actual_node
@@ -766,8 +769,11 @@ INSERT INTO nodes (
wc_id, local_relpath, op_depth, parent_relpath, presence, kind)
SELECT wc_id, local_relpath, ?4 /*op_depth*/, parent_relpath, 'base-deleted',
kind
-FROM nodes_current
-WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')
+FROM nodes
+WHERE wc_id = ?1
+ AND (local_relpath = ?2
+ OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+ AND op_depth = ?3
AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent')
-- STMT_INSERT_WORKING_NODE_FROM_BASE_COPY
@@ -1155,9 +1161,15 @@ CREATE TEMPORARY TABLE delete_list (
/* This matches the selection in STMT_INSERT_DELETE_FROM_NODE_RECURSIVE */
-- STMT_INSERT_DELETE_LIST
INSERT INTO delete_list(local_relpath)
-SELECT local_relpath FROM nodes_current
-WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')
+SELECT local_relpath FROM nodes n
+WHERE wc_id = ?1
+ AND (local_relpath = ?2
+ OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+ AND op_depth >= ?3
AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent')
+ AND op_depth = (SELECT MAX(op_depth) FROM nodes s
+ WHERE s.wc_id = n.wc_id
+ AND s.local_relpath = n.local_relpath)
-- STMT_SELECT_DELETE_LIST
SELECT local_relpath FROM 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=1104056&r1=1104055&r2=1104056&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue May 17 08:47:00 2011
@@ -5532,8 +5532,8 @@ op_revert_recursive_txn(void *baton,
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
STMT_DELETE_NODES_RECURSIVE));
- SVN_ERR(svn_sqlite__bindf(stmt, "issi", wcroot->wc_id,
- local_relpath, like_arg, op_depth));
+ SVN_ERR(svn_sqlite__bindf(stmt, "isi", wcroot->wc_id,
+ local_relpath, op_depth));
SVN_ERR(svn_sqlite__step_done(stmt));
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
@@ -5943,10 +5943,8 @@ remove_node_txn(void *baton,
STMT_DELETE_NODES_RECURSIVE));
/* Remove all nodes at or below local_relpath where op_depth >= 0 */
- SVN_ERR(svn_sqlite__bindf(stmt, "issi", wcroot->wc_id,
- local_relpath,
- like_arg,
- (apr_int64_t)0));
+ SVN_ERR(svn_sqlite__bindf(stmt, "isi",
+ wcroot->wc_id, local_relpath, (apr_int64_t)0));
SVN_ERR(svn_sqlite__step_done(stmt));
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
@@ -6227,6 +6225,8 @@ op_delete_txn(void *baton,
svn_boolean_t add_work = FALSE;
svn_sqlite__stmt_t *stmt;
const char *like_arg;
+ apr_int64_t select_depth; /* Depth of what is to be deleted */
+ svn_boolean_t refetch_depth = FALSE;
SVN_ERR(svn_sqlite__exec_statements(wcroot->sdb, STMT_CREATE_DELETE_LIST));
@@ -6244,38 +6244,48 @@ op_delete_txn(void *baton,
if (op_root)
{
- svn_boolean_t below_base;
- svn_boolean_t below_work;
+ svn_boolean_t have_base;
+ svn_boolean_t have_work;
svn_wc__db_status_t below_status;
-
+ SVN_DBG(("Deleting %s\n", local_relpath));
/* Use STMT_SELECT_NODE_INFO directly instead of read_info plus
info_below_working */
- SVN_ERR(info_below_working(&below_base, &below_work, &below_status,
+ SVN_ERR(info_below_working(&have_base, &have_work, &below_status,
wcroot, local_relpath, -1, scratch_pool));
- if ((below_base || below_work)
+ if ((have_base || have_work)
&& below_status != svn_wc__db_status_not_present
&& below_status != svn_wc__db_status_deleted)
- add_work = TRUE;
+ {
+ add_work = TRUE;
+ refetch_depth = TRUE;
+ }
+
+ select_depth = relpath_depth(local_relpath);
}
else
- add_work = TRUE;
+ {
+ add_work = TRUE;
+ SVN_ERR(op_depth_of(&select_depth, wcroot, local_relpath));
+ }
like_arg = construct_like_arg(local_relpath, scratch_pool);
/* ### Put actual-only nodes into the list? */
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
STMT_INSERT_DELETE_LIST));
- SVN_ERR(svn_sqlite__bindf(stmt, "iss",
- wcroot->wc_id, local_relpath, like_arg));
+ SVN_ERR(svn_sqlite__bindf(stmt, "isi",
+ wcroot->wc_id, local_relpath, select_depth));
SVN_ERR(svn_sqlite__step_done(stmt));
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
STMT_DELETE_NODES_RECURSIVE));
- SVN_ERR(svn_sqlite__bindf(stmt, "issi",
- wcroot->wc_id, local_relpath, like_arg,
- b->delete_depth));
+ SVN_ERR(svn_sqlite__bindf(stmt, "isi",
+ wcroot->wc_id, local_relpath, b->delete_depth));
SVN_ERR(svn_sqlite__step_done(stmt));
+ if (refetch_depth)
+ SVN_ERR(op_depth_of(&select_depth, wcroot, local_relpath));
+
/* Delete ACTUAL_NODE rows, but leave those that have changelist
and a NODES row. */
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
@@ -6300,9 +6310,9 @@ op_delete_txn(void *baton,
{
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
STMT_INSERT_DELETE_FROM_NODE_RECURSIVE));
- SVN_ERR(svn_sqlite__bindf(stmt, "issi",
- wcroot->wc_id, local_relpath, like_arg,
- b->delete_depth));
+ SVN_ERR(svn_sqlite__bindf(stmt, "isii",
+ wcroot->wc_id, local_relpath,
+ select_depth, b->delete_depth));
SVN_ERR(svn_sqlite__step_done(stmt));
}