Open umpirsky opened 6 years ago
@umpirsky this is because the removal is scheduled in the UnitOfWork
, not in the dedicated persister. Optimising that for a batch of entities of the same type (and therefore any deletion at all) should be feasible, check https://github.com/doctrine/doctrine2/blob/b40c2c6b7893c929f754150d480c20f9b22e0afe/lib/Doctrine/ORM/UnitOfWork.php#L1028-L1033
@Ocramius Thanks for pointing me in the right direction!
So, grouping per entity type should be easy, but how to do bulk operations? Using $persister->delete($entity);
should be replaced with something else that is capable of bulk delete? Sounds like lower level operation then what EntityPersister
is capable of in the current implementation.
Should probably be $persister->deleteBulk($entities)
The bulk deletion is something we can then add to DBAL, like in https://github.com/doctrine/dbal/pull/682
Wow, that would be great! Thanks for linking that, good to see bulk insert shaping up. :+1:
It's not moving since ages, and requires work :-P
Oh, only now spotted timestamps!
In current implementation
cascade={"remove"}
producesDELETE
query for each record on the "Many" side. That can be manyDELETE
queries if there are many related records. :)Is it possible to implement (or override outside of Doctrine itself) bulk deletion with single
DELETE FROM table WHERE id IN (...)
query?