You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently deleteMany fetches the rows to be deleted and then deletes the rows that results in two queries. Probably this was implemented due to cascade deletes not working.
Suggested solution
deleteMany should use only a single query that deletes the specified items.
This is a crazy way to implement a delete with a filter. If I want to delete a lot of rows, it will run out of memory and crash. Why would the client want to fetch all that data to only pick the ids and run a query that could as easily have been run directly with the where clauses?
+1 on the Prisma team addressing this ASAP. Our app had OOMs and timeouts for very large batch deletes because Prisma hauls back all of the rows that need to be deleted to then use in an IN clause when it just needs a filtered DELETE command. I have to say the current approach is a bonkers bad way of doing a filtered DELETE for any large amount of data. In the mean time, we're using prisma.$executeRaw.
Reacted by Paolo Mosconi, Jacob Lauritzen and J. Brandon Johnson
Activity
ecker00 commentedon Jan 14, 2023
Any updates on this? Notice that it's rather slow to end up running a raw query instead.
baptisteArno commentedon Feb 16, 2023
Is there already someone working on this? I'd be willing to contribute! Or would it be too complicated?
tbell511 commentedon Apr 1, 2023
Are there any updates on this?
Jacse commentedon May 8, 2023
This is a crazy way to implement a delete with a filter. If I want to delete a lot of rows, it will run out of memory and crash. Why would the client want to fetch all that data to only pick the ids and run a query that could as easily have been run directly with the where clauses?
njpearman commentedon Aug 2, 2023
+1 on the Prisma team addressing this ASAP. Our app had OOMs and timeouts for very large batch deletes because Prisma hauls back all of the rows that need to be deleted to then use in an
INclause when it just needs a filteredDELETEcommand. I have to say the current approach is a bonkers bad way of doing a filteredDELETEfor any large amount of data. In the mean time, we're usingprisma.$executeRaw.Jolg42 commentedon Oct 9, 2023
The optimization is now available since
5.4.0, for more details check out the bottom part of the release notes:https://github.com/prisma/prisma/releases/tag/5.4.0