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? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
My package
postgres_crdt
usespostgres
to 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.
Sqflite
has abatch
method 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
postgres
API, or if there are other strategies that could help in my case that I'm missing.Beta Was this translation helpful? Give feedback.
All reactions