orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Very slow updating of data compared with creating

Open scrabb opened this issue 4 years ago • 1 comments

OrientDB Version: 3.1.7

Java Version: 15

OS: Windows

Expected behavior

Updating records that do not change the size of the record should take a similar amount of time as creating them

Actual behavior

Updating is between 4 and 18 times slower

Steps to reproduce

String testClass = "TestUpdate2";
final OSchema schema = db.getMetadata().getSchema();
if (!schema.existsClass(testClass)) {
        db.createClass(testClass);
}
System.out.println("Creating...");
long begin = System.currentTimeMillis();
for (int i = 0; i < 1_000_000; i++) {
        final OElement doc = db.newInstance(testClass);
        doc.setProperty("Int", 0);
        doc.save();
}
long diff = System.currentTimeMillis() - begin;
System.out.println("time " + DurationFormatUtils.formatDurationHMS(diff));
System.out.println("Updating...");
final OResultSet results = db.query("select from TestUpdate limit -1");
begin = System.currentTimeMillis();
while (results.hasNext()) {
          final OElement doc = results.next().toElement();
          doc.setProperty("Int", 1);
          doc.save();
}
results.close();
long diff = System.currentTimeMillis() - begin;
System.out.println("time " + DurationFormatUtils.formatDurationHMS(diff));

Running VisualVM shows that it spends 50% of the time on the update doing a method called OClusterPage.doDefragementation(), however the actual record size has not changed so it seems a bit strange that it would have to deal with the possibility of fragmentation.

scrabb avatar Feb 05 '21 08:02 scrabb

@laa any news on this?

lvca avatar Jun 26 '21 00:06 lvca