简体   繁体   中英

OrientDB - don't release memory after insert

I use NodeJS for insert 8.000.000 records into my orientdb database, but after about 2.000.000 insert records my app is stopped and show error "Java Heap".

Is there a way for release memory after every record inserted?

Ram usage:
-befor start app: 2.6g
-after insert 2milions records: 7.6g

My app.js (NodeJS):

var dbConn = [];
var dbNext = 0;
var dbMax = 25;

for (var i = 0; i <= dbMax; i++) {
  var db = new ODatabase({
      host: orientdb.host,
      port: 2424,
      username: 'root',
      password: orientdb.password,
      name: 'test',
  });
  dbConn.push(db);
}
//---------------------------------------------------
//Start loop
// record = {name: 'test'}
record["@class"] = "table";
var db = nextDB();
db.open().then(function () {
    return db.record.create(record);
}).then(function (res) {
    db.close().then(function () {
             //----resume loop
    });
  }).error(function (err) {
          //------
  });
// end loop - iteration loop
//---------------------------------------------------
function nextDB() {
  if (++dbNext >= dbMax) {
      dbNext -= dbMax;
  }
  return dbConn[dbNext];
}

OrientJS wasn't efficient for insert massive data from SqlServer to OrientDB . I used ETL module for massive insert, that is fastest way and good idea for transpot massive data without increase memory more than 2GB.
I could transported 7.000 records per minute.

My ETL's config.json:

{
  "config": {
    log : "debug"
  },
  "extractor" : {
    "jdbc": { "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
              "url": "jdbc:sqlserver://10.10.10.10;databaseName=My_DB;",
              "userName": "sa",
              "userPassword": "123",
              "query": "select * from My_Table" 
            }
  },

  "transformers" : [
    { "vertex": { "class": "Company"} }
  ],
   "loader" : {
    "orientdb": {
      "dbURL": "plocal:D:\DB\Orient_DB",
      dbUser: "admin",
      dbPassword: "admin",
      "dbAutoCreate": true,
      "tx": false,
      "batchCommit": 1000,
      "wal" : false,
      "dbType": "graph"
    }
  }
}

From the documentation , for massive insertion you should declare your intention :

db.declareIntent( new OIntentMassiveInsert() );
// YOUR MASSIVE INSERTION    
db.declareIntent( null );

But by now it seems not implemented in orientJS driver. Another thing is that you should not open/close your database for each new record created. This is in general bad practise.

I do not have the node.js environment by now but something like this should do the trick:

db.open().then(function () {
  // when available // db.declareIntent( new OIntentMassiveInsert() );
  for (var i = 0; i < 8000000; i++) {
    // create a new record
    myRecord = { "@class" : "myClass", "attributePosition" : i };
    db.record.create(myRecord);
  }
  // when available // db.declareIntent( null );

}).then(function () { db.close() });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM