From 735667b51cf74e6e12ca83374d5cf19f35c5bf40 Mon Sep 17 00:00:00 2001 From: randomdan Date: Sun, 13 Feb 2011 01:43:50 +0000 Subject: Minor tweaks to improve perforamce on PG bulk deletes Fixes to support partial merges with bulk updates --- project2/tablepatch.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/project2/tablepatch.cpp b/project2/tablepatch.cpp index 3533b65..aacedbb 100644 --- a/project2/tablepatch.cpp +++ b/project2/tablepatch.cpp @@ -254,7 +254,7 @@ TablePatch::doUpdates(const char * where, const char * order) // Build SQL for list of updates to perform ------------------------ // ----------------------------------------------------------------- Buffer updSql; - updSql.appendf("UPDATE %s SET ", + updSql.appendf("UPDATE %s a SET ", dest.c_str()); bool first = true; foreach (Columns::const_iterator, cols, col) { @@ -276,8 +276,8 @@ TablePatch::doUpdates(const char * where, const char * order) else { updSql.append(" AND "); } - updSql.appendf(" %s.%s = b.%s ", - dest.c_str(), pki->c_str(), pki->c_str()); + updSql.appendf(" a.%s = b.%s ", + pki->c_str(), pki->c_str()); } updSql.append(" AND ("); first = true; @@ -288,10 +288,10 @@ TablePatch::doUpdates(const char * where, const char * order) } first = false; updSql.appendf( - " (((CASE WHEN (%s.%s IS NULL AND b.%s IS NULL) THEN 1 ELSE 0 END) \ - + (CASE WHEN(%s.%s = b.%s) THEN 1 ELSE 0 END)) = 0)", - dest.c_str(), col->c_str(), col->c_str(), - dest.c_str(), col->c_str(), col->c_str()); + " (((CASE WHEN (a.%s IS NULL AND b.%s IS NULL) THEN 1 ELSE 0 END) \ + + (CASE WHEN(a.%s = b.%s) THEN 1 ELSE 0 END)) = 0)", + col->c_str(), col->c_str(), + col->c_str(), col->c_str()); } } updSql.append(")"); -- cgit v1.2.3