Replies: 2 comments 4 replies
I assume this is 10k individual One performance bottleneck you may be hitting here is an implementation detail of the 3.x version of the package: we decided to wait for each query to have their own values completed before sending in the next query, which, in this case, may add a few milliseconds here and there. In that regard it may be better to send a huge insert with statement with 100s of records than rewriting the package and queue up the queries to postgres earlier.
Any idea how that would look like? |
|
I'd expect this to work:
I think this is coming from Postgresql, 42601 is a generic error code for syntax error, and the message makes it specific. |
Uh oh!
There was an error while loading. Please reload this page.
My package
postgres_crdtusespostgresto interface with the database backend, and one of its main features is being able to merge sometimes large datasets from other nodes in the network.I created a simple benchmark that merges 10k records. On my machine it takes 10+ seconds as individual queries; ~2s using transactions, and ~1.5s using transactions and prepared statements.
I suppose the meager improvement when using prepared statements is because each statement is still causing a roundtrip to the database, so I'd like to ideally find a way to avoid that overhead if possible.
Sqflitehas abatchmethod that collects multiple queries on the Dart side and executes them in a single call to Sqlite. In the same benchmark I'm seeing 4x performance improvements using that strategy, and I suspect the gains would be much better for Postgres since it's using network rather than IPC calls.Though I haven't been able to find a direct equivalent for Postgres, it seems to be possible to pass multiple values using prepared statements - if I'm reading this SO answer correctly:
I wonder if it would be possible to expose this mechanic via the
postgresAPI, or if there are other strategies that could help in my case that I'm missing.All reactions