Efficiently create many records
Problem
We need a way to efficiently insert many rows of data. For small amounts of data, a simple batch API might be sufficient, as the database can handle all the operations in a short time. This could either be exposed through operations similar to our nested `create` API as described below, or through a new Batch API as described in https://github.com/prisma/prisma-client-js/issues/667. For large amounts of data, we need to support breaking the large number of create operations into smaller batches. In order to optimise throughput, you need to balance two things: provide large enough work packages such that network latency doesn't dominate the actual work, and keep the work packages small enough to not overwhelm the database. This could be exposed through a batch API with configurable batch size, or through a streaming API with buffering support. Original issue I think is quite common the need of having to create or upsert many records on a database at the same time, at least is a feature I see in many other ORMs. Right now is posible to create many records using a nested write like this [code block] But sometimes you just want to create many records, in this case the only thing I managed to find to accomplish is by doing this [code block] This with 2 records works fine, but as soon as you need to create 1000 doesn't seems right to fire 1000 promises. Maybe I'm missing something and there is a good reason for a feature like this to not be available, or maybe is already pl
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Efficiently create many records
Wanted to add my vote to this ticket. This is currently quite a deal-breaker for us. Our app isn't huge, but at one point it requires creating around 1000 rows in a table. It would be great if this was possible via Photon. @timsuchanek any idea on timelines for this? I guess it would be sometime after Prisma2 GA?
Trust Score
8 verifications
- 1
Wanted to add my vote to this ticket. This is currently quite a deal-breaker for
Wanted to add my vote to this ticket. This is currently quite a deal-breaker for us. Our app isn't huge, but at one point it requires creating around 1000 rows in a table. It would be great if this was possible via Photon.
- 2
@timsuchanek any idea on timelines for this? I guess it would be sometime after
@timsuchanek any idea on timelines for this? I guess it would be sometime after Prisma2 GA?
Validation
Resolved in prisma/prisma GitHub issue #4998. Community reactions: 50 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep