text: Q:
  
  When should I unset in PHP to improve performance
  
  I am using the following code:
  for ($x = 0; $x < count($response[0]); $x++) { //approx count 50-60
  
      $t = $response[0][$x];
      $query = "INSERT INTO tableX (time,title) VALUES ('$date','$t')";
  
      if ($query_run = mysqli_query($mysql_connect, $query)) {
  
      //Call some functions if the insertion happens
  
      }
  }
  
  mysqli_close($mysql_connect);
  
  Title in the table is a pimary key. I am going to call some functions only when the insertion is successful i.e., no existing title is provided. The title and date are derived from a csv file.
  How can I improve the performance of this code? When should I use unset to save CPU memory cycles? 
  
  A:
  
  unset will not improve performance by any meaningful metric here.
  What will improve performance is updating more than one row per query.
  Let's take your code as an example. This is just an example of how it could be. If you need to run other functions after the insert, then you might want to update for example 10 or 100 rows at a time instead of ALL rows.
  $query = "INSERT INTO tableX (time,title) VALUES ";
  $valueQuery = array();
  
  for ($x = 0; $x < count($response[0]); $x++) { //approx count 50-60
      $t = $response[0][$x];
      $valueQuery[] =  "('$date','$t')";
  }
  $query .= implode(", ",$valueQuery);
  
  if ($query_run = mysqli_query($mysql_connect, $query)) {
      //Call some functions if the insertion happens
  }
  
  A:
  
  This question is entirely based on the wrong premises.
  First of all, nowhere using unset will save you a CPU cycle,but will rather cousume them.
  Besides, there is not much place to put unset anyway.
  Finally, there are no real issues with performance with this code. If you are experiencing any, you should meausere them, detect a real bottleneck, and then fix it, instead of poking around barking at random trees.
  What should be your actual concern, instead of fictional performance issues, is that your code wide open to sql injections and syntax errors of all sorts.
  
  