How fast is flush()? I’m adding several thousand item to a collection with persist(), then emptying the collection then flushing it.
$dm = $this->get('doctrine.odm.mongodb.document_manager');
while(stuff))
{
$item = new Item();
$item->setItem("item stuff");
$dm->persist($item);
}
$qb = $dm->createQueryBuilder('Bundle:Item')->remove();
$query = $qb->getQuery();
$query->execute();
$dm->flush();
I want to know how much time will the collection stay empty. Between the remove and the flush.
I created a benchmark to profile flushes of a simple two-field document in various batch sizes: https://gist.github.com/2725976
As you might expect, actually inserting the data into Mongo only accounts for a small fraction of these measurements. Doctrine is going to spent quite a bit of time walking through steps like events dispatching and changeset computation, the latter of which will be significantly impacted by the complexity of your domain model.
You can trace all of the Doctrine-specific operations in
flush()by taking a look at UnitOfWork::commit().