Project

General

Profile

« Previous | Next » 

Revision 3507

Added by Jing Tao about 17 years ago

Modified a sql command from "like" to "=". It dramatically improves the peformance of build index.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
1262 1262
    public void buildIndex() throws McdbException
1263 1263
    {
1264 1264
    	logMetacat.warn("buildIndex called on docid " + docid);
1265
    	double start = System.currentTimeMillis()/1000;
1265 1266
        TreeSet nodeRecordLists = getNodeRecordList(rootnodeid);
1266 1267
        boolean atRootElement = true;
1267 1268
        long rootNodeId = -1;
......
1277 1278
        }
1278 1279

  
1279 1280
        String doc = docid;
1280

  
1281
      double afterPutNode = System.currentTimeMillis()/1000;
1282
      logMetacat.info("The time for put node id into map is "+(afterPutNode - start));
1283
      double afterDelete = 0;
1281 1284
        // Opening separate db connection for deleting and writing
1282 1285
        // XML Index -- be sure that it is all in one db transaction
1283 1286
        int serialNumber = -1;
......
1291 1294

  
1292 1295
            // Delete the previous index entries for this document
1293 1296
            deleteNodeIndex(dbConn);
1294

  
1297
            afterDelete = System.currentTimeMillis()/1000;
1295 1298
            // Step through all of the node records we were given
1296 1299
            // and build the new index and update the database. Process
1297 1300
            // TEXT nodes with their parent ELEMENT node ids to associate the
......
1360 1363
        } finally {
1361 1364
            DBConnectionPool.returnDBConnection(dbConn, serialNumber);
1362 1365
        }
1363
        
1366
        double finish = System.currentTimeMillis()/1000;
1367
        logMetacat.info("The time for inserting is "+(finish - afterDelete));
1364 1368
    	logMetacat.warn("BuildIndex complete for docid " + docid);
1365 1369

  
1366 1370
        // Adds the docid to the spatial data cache 
......
1478 1482
    private void deleteNodeIndex(DBConnection conn) throws SQLException
1479 1483
    {
1480 1484
        //String familyId = MetaCatUtil.getDocIdFromString(docid);
1485
    	double start = System.currentTimeMillis()/1000;
1481 1486
        String familyId = docid;
1482
        String sql = "DELETE FROM xml_index WHERE docid LIKE ?";
1487
        String sql = "DELETE FROM xml_index WHERE docid = ?";
1483 1488
        logMetacat.debug(sql);
1484 1489
        logMetacat.debug("SQL is: " + sql);
1485 1490

  
......
1494 1499
        pstmt.close();
1495 1500
        logMetacat.info("Deleted " + rows + " rows from xml_index " +
1496 1501
            "for document " + docid);
1497

  
1502
        double afterDeleteIndex = System.currentTimeMillis()/1000;
1503
        logMetacat.info("The delete index time is "+(afterDeleteIndex - start));
1498 1504
        // Delete all the entries in xml_queryresult
1499 1505
        pstmt = conn.prepareStatement(
1500 1506
                "DELETE FROM xml_queryresult WHERE docid = ?");
......
1504 1510
        pstmt.close();
1505 1511
        logMetacat.info("Deleted " + rows + " rows from xml_queryresult " +
1506 1512
                "for document " + docid);
1507

  
1513
        double afterDeleteQueryResult = System.currentTimeMillis()/1000;
1514
        logMetacat.info("The delete query result time is "+(afterDeleteQueryResult - afterDeleteIndex ));
1508 1515
        // Delete all the entries in xml_path_index
1509 1516
        pstmt = conn.prepareStatement(
1510 1517
                "DELETE FROM xml_path_index WHERE docid = ?");
......
1512 1519
        rows = pstmt.executeUpdate();
1513 1520
        conn.increaseUsageCount(1);
1514 1521
        pstmt.close();
1522
        double afterDeletePathIndex = System.currentTimeMillis()/1000;
1523
        logMetacat.info("The delete path index time is "+ (afterDeletePathIndex - afterDeleteQueryResult));
1515 1524
        logMetacat.info("Deleted " + rows + " rows from xml_path_index " +
1516 1525
                "for document " + docid);
1517 1526

  

Also available in: Unified diff