Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java |
— | — | @@ -289,13 +289,21 @@ |
290 | 290 | |
291 | 291 | ReferenceField f = (ReferenceField)ref.getField(refField); |
292 | 292 | String field = f.getTargetField(); |
293 | | - |
| 293 | + |
| 294 | + /* |
294 | 295 | sql = "DELETE FROM " + table.getSQLName() + " "; |
295 | 296 | sql += " WHERE NOT EXISTS ( "; |
296 | 297 | sql += " SELECT * FROM " + ref.getSQLName() + " AS R "; |
297 | 298 | sql += " WHERE R." + refField + " = "+ table.getSQLName() + "." + field; |
298 | 299 | sql += " )"; |
| 300 | + */ |
299 | 301 | |
| 302 | + sql = "DELETE FROM E "; |
| 303 | + sql += " USING " + table.getSQLName() + " AS E "; |
| 304 | + sql += " LEFT JOIN " + ref.getSQLName() + " AS R "; |
| 305 | + sql += " ON R." + refField + " = E." + field; |
| 306 | + sql += " WHERE R." + refField + " IS NULL;"; |
| 307 | + |
300 | 308 | long t = System.currentTimeMillis(); |
301 | 309 | int c = executeUpdate("deleteDataFrom", sql); |
302 | 310 | trace("deleted "+c+" orphan rows from "+table.getName()+" where no reference exists from "+ref.getSQLName()+"."+refField+", took "+(System.currentTimeMillis()-t)/1000+" sec"); |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java |
— | — | @@ -250,7 +250,8 @@ |
251 | 251 | deleteDataFrom(rcId, op, langlinkTable, "resource"); |
252 | 252 | deleteDataFrom(rcId, op, broaderTable, "resource"); |
253 | 253 | |
254 | | - deleteDataFrom(rcId, op, conceptTable, "id", aboutTable, "concept", "resource", true); |
| 254 | + deleteDataFrom(rcId, op, aboutTable, "resource"); |
| 255 | + deleteOrphansFrom(rcId, op, conceptTable, aboutTable, "concept"); |
255 | 256 | |
256 | 257 | deleteDataFrom(rcId, op, aliasTable, "resource"); |
257 | 258 | deleteDataFrom(rcId, op, sectionTable, "resource"); |