I have two entites:
Voucher
Support
Those entities have a join table called
voucher_support
When i add 1000 existing supports to a new voucher, it will call 1000 INSERT queries at voucher_support to my SQL server. With 50.000 for sure also 50.000 inserts.
How can i achieve that doctrine just makes a single INSERT and improve my performance?
EDIT:
I think bulk insertation is not the solution. Here is my current Code for better understanding:
$voucher = new Voucher();
$voucher->setCreatedAt(new \DateTime());
$supports = $this->em->getRepository('Support')->getOpen();
foreach($supports as $support){
// this generates for each support a INSERT in join table.
$voucher->addSupport($support);
}
$this->em->persist($voucher);
$this->em->flush();