Jaguar-dart / jaguar_orm

Source-generated ORM with relations (one-to-one, one-to-many, many-to-many), preloading, cascading, polymorphic relations, etc
https://jaguar-dart.github.io
BSD 3-Clause "New" or "Revised" License
217 stars 52 forks source link

SqfliteAdapter batching is unused #85

Closed thomasostfeld closed 5 years ago

thomasostfeld commented 5 years ago

Both updateMany and upsertMany create and commit a batch in SqfliteAdapter.

The batch isn't used to execute any of the queries though, they are instead directly handled by the connection.

Future<void> upsertMany<T>(UpsertMany st) async {
  List<String> strSt = composeUpsertMany(st);
  final batch = connection.batch();
  for (var query in strSt) {
    connection.execute(query);
  }
  return batch.commit(noResult: true);
}

Instead of connection.execute(query); the query should be executed by the batch: batch.execute(query);

In my test this gave me a big performance boost of about 10x.

tejainece commented 5 years ago

Can you make a pr?

tejainece commented 5 years ago

@jaumard

jaumard commented 5 years ago

nice catch @ozzy91 ! Miss that one :) thanks for the report!