Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7964439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:53:33+00:00 2026-06-04T05:53:33+00:00

How fast is flush()? I’m adding several thousand item to a collection with persist(),

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:53:34+00:00Added an answer on June 4, 2026 at 5:53 am

    I created a benchmark to profile flushes of a simple two-field document in various batch sizes: https://gist.github.com/2725976

    $ php src/benchmark.php 10 100 1000 10000 20000 50000 100000
    Flushing     10 items took  0.014058 seconds and   2097152 bytes
    Flushing    100 items took  0.024325 seconds and    524288 bytes
    Flushing   1000 items took  0.196992 seconds and   5505024 bytes
    Flushing  10000 items took  2.563700 seconds and  57933824 bytes
    Flushing  20000 items took  6.291873 seconds and  89915392 bytes
    Flushing  50000 items took 19.118011 seconds and 240386048 bytes
    Flushing 100000 items took 58.582809 seconds and 469499904 bytes
    

    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().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using Fast CGI I can't get it to read the php.ini file. See my
How fast in frames per second can an iphone 4s take screenshots? What would
Is it generally fast enough to make simple updates synchronously? For instance with a
It seems fast, what could be its compression level? Can it be changed? I'm
I am looking for fast class for to work with text files and comfortable
Is there any fast implementation of cryptographically secure pseudorandom number generator (CSPRNG) for C#
is there a fast algorithm, similar to power of 2, which can be used
Can someone suggest a fast 2 way encryption algorithm for long ints? My candidates
For all those ligthning fast shop users. I'm trying to implement my own first
Is there any fast algorithm that allows to compare two files (for verification purpose)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.