r54183 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54182‎ | r54183 | r54184 >
Date:20:06, 1 August 2009
Author:daniel
Status:deferred
Tags:
Comment:
use multi-row delete with join instead of deleting orphans using a subquery
Modified paths:
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java
@@ -259,18 +259,20 @@
260260 */
261261
262262 protected void deleteDataFrom(int rcId, String op, DatabaseTable rel, String field) throws PersistenceException {
263 - deleteDataFrom(rcId, op, rel, field, null, null, null);
 263+ deleteDataFrom(rcId, op, rel, field, null, null, null, false);
264264 }
265265
266 - protected void deleteDataFrom(int rcId, String op, DatabaseTable rel, String field, DatabaseTable via, String viaJoinField, String viaField) throws PersistenceException {
 266+ protected void deleteDataFrom(int rcId, String op, DatabaseTable rel, String field, DatabaseTable via, String viaJoinField, String viaField, boolean deleteVia) throws PersistenceException {
267267 String sql;
268268
269269 if (via!=null) {
270 - sql = "DELETE FROM T";
271 - sql += " USING "+rel.getSQLName()+" AS T ";
 270+ sql = "DELETE ";
 271+ if (deleteVia) sql += " T, C FROM ";
 272+ else sql += " FROM T USING ";
 273+ sql += rel.getSQLName()+" AS T ";
272274 sql += " LEFT JOIN "+via.getSQLName()+" AS C";
273275 sql += " ON T."+field+" = C."+viaJoinField+" ";
274 - sql += " WHERE "+viaField+" "+op+" "+rcId;
 276+ sql += " WHERE C."+viaField+" "+op+" "+rcId;
275277 }
276278 else {
277279 sql = "DELETE FROM "+rel.getSQLName();
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java
@@ -250,8 +250,7 @@
251251 deleteDataFrom(rcId, op, langlinkTable, "resource");
252252 deleteDataFrom(rcId, op, broaderTable, "resource");
253253
254 - deleteDataFrom(rcId, op, aboutTable, "resource");
255 - deleteOrphansFrom(rcId, op, conceptTable, aboutTable, "concept");
 254+ deleteDataFrom(rcId, op, conceptTable, "id", aboutTable, "concept", "resource", true);
256255
257256 deleteDataFrom(rcId, op, aliasTable, "resource");
258257 deleteDataFrom(rcId, op, sectionTable, "resource");

Status & tagging log