Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think there are two parts that may be optimized in your script.</p> <ul> <li>The way you read your CSV files, depending on how you load it, you either totally load it in memory (using <code>file_get_contents()</code> or <code>file()</code> for example), or reading it chunck by chunck with <code>fopen()</code>, <code>fread()</code>.</li> </ul> <p>The last option is prefered because it will only take the necessary amount of memory when processing a bunch of lines.</p> <ul> <li>You need to <code>clear()</code> the object you already processed, else it will be kept in memory until the end of your script. This means that if one DC2 object uses 1Mo of memory, and you have 100,000 objects, at the end of your scripts it will use 100,000Mo. So batching your insert by range of 2,500 is quite a good idea but you obviously need to remove the processed object from the EntityManager.</li> </ul> <p>It can be done using <code>$entityManager-&gt;clear();</code> </p> <p>The <code>clear()</code> will clear the whole <code>EntityManager</code>, you want to clear a single entity, you may use <code>$entityManager-&gt;detach($object)</code>.</p> <hr> <p>If you want to profile your memory usage you may also be interested in the functions </p> <p><a href="http://www.php.net/manual/en/function.memory-get-usage.php" rel="nofollow"><code>memory_get_usage()</code></a></p> <p><a href="http://php.net/manual/en/function.memory-get-peak-usage.php" rel="nofollow"><code>memory_get_peak_usage()</code></a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload