myql performance : extremely slow inserts on a faster box tldr; When migrating a stack to its pre-prod environment, i am confronted with a setup script taking 50x the amount of time to execute compared to my dev box. error logs are dead silent !

dev :
    osx, mysql 5.7, SSD, plenty of memory

pre-prod :
    debian 8.6, mysql 5.6, faster SSD, faster/more memory, faster core.

the PHP script:

    private function _addCityFile($fn)
    {
        $this-&gt;log-&gt;info(__METHOD__ . " start.");

        $this-&gt;log-&gt;debug("Adding city file [$fn]");

        try {
            /** @var \PDO $pdo */
            $pdo = $this-&gt;pdo;
            $this-&gt;pdo-&gt;beginTransaction();
            // InnoDB table
            $sql  = "INSERT INTO City SET country=:co,city=:ci,state=:st,zip=:zip";
            $stmt = $pdo-&gt;prepare($sql);

            $handle             = fopen($fn , "r");
            $csv_time           = 0.0;
            $pdo_time           = 0.0;
            $index              = 0;
            $intermediate_count = 100;           // echo every 100 records
            $total_count        = 0;

            if ($handle) {
                fgets($handle);                 // skip first line
                while (true) {
                    $index++;
                    $total_count++;
                    $start_csv_once = microtime(true);
                    $ary            = fgetcsv($handle);
                    $end_csv_once   = microtime(true);
                    $csv_time_once  = $end_csv_once - $start_csv_once;
                    $csv_time       = $csv_time + $csv_time_once;

                    if ($ary) {
                        $country = $ary[0];
                        $state   = $ary[1];
                        $city    = $ary[2];
                        if (!$city || $city === '') continue;
                        $zip = strtoupper($ary[3]);
                        if (!$zip || $zip === '') continue;
                        $stmt-&gt;bindValue('co' , $country , \PDO::PARAM_STR);
                        $stmt-&gt;bindValue('ci' , $city , \PDO::PARAM_STR);
                        $stmt-&gt;bindValue('st' , $state , \PDO::PARAM_STR);
                        $stmt-&gt;bindValue('zip' , $zip , \PDO::PARAM_STR);
                        $start_pdo_once = microtime(true);
                        $stmt-&gt;execute();
                        $end_pdo_once  = microtime(true);
                        $pdo_time_once = $end_pdo_once - $start_pdo_once;
                        $pdo_time += $pdo_time_once;
                        $ct = $csv_time * 1000;
                        $pt = $pdo_time * 1000;
                        if ($index &gt;= $intermediate_count) {
                            $this-&gt;log-&gt;debug("After $total_count : csv [{$ct} ms.], pdo [{$pt}]");
                            $index = 0;
//                          if ($total_count &gt; 1000) break;
                        }

                    } else {
                        break;
                    }
                }
                $start_commit = microtime(true);
                $this-&gt;pdo-&gt;commit();
                $end_commit = microtime(true);
                $delayInMs  = ($end_commit - $start_commit) * 1000;
                $this-&gt;log-&gt;debug("Commit took [$delayInMs] ms.");
                fclose($handle);
            }
        } catch (\Exception $e) {
            $this-&gt;pdo-&gt;rollBack();
            $this-&gt;log-&gt;error(prettyStack($e , "While processing [$fn]"));
        }
        $this-&gt;log-&gt;info(__METHOD__ . " end.");

    }


the puzzle:

the script takes about 3.5 seconds per 1000 records on pre-prod, dev takes .07 seconds/1000 records on dev. 

Following some guidance i found on SO, i added the beginTransaction / commit.  With that, i get .04 seconds (!!!) /1000 records on pre-prod vs .06 on dev.

the question

There must be some obvious mysql setting that explains this rather large difference. I compared both configurations, but cant find anything fundamentally different except 5.7/5.6. Any suggestions in what direction to look?
Do not insert one row at a time; batch them.  That is, have 1000 rows being inserted by each INSERT statement.

That will help both servers

To find out why there is a difference, ...  Compare the CREATE TABLE.  Compare SHOW VARIABLES LIKE 'innodb%';.  If those don't point out anything, compare all the VARIABLES.  The likely suspect is innodb_flush_log_at_trx_commit.  Note:  Don't simply look at my.cnf; some defaults are different between versions.