Question: I'm creating a project that will regularly need to update around 300,000 files a day in an existing INNODB table of about 110,000,000 records using REPLACE INTO from query syntax. I've been looking into ways to optimize this more and found START TRANSACTION / COMMIT, but I'm not sure I'm doing this right. Is it only best done in a multi query? Currently I'm doing this, and seeing no real benefit:

```
$mysqli->query("START TRANSACTION")or die(mysqli_error($mysqli));

$mysqli->query("REPLACE INTO `TABLE1` (field list) SELECT fields FROM `TABLE2`")or die(mysqli_error($mysqli));

$mysqli->query("COMMIT")or die(mysqli_error($mysqli));

```

Answer: 
There isn't a real benefit in wrapping a single query in a transaction. You might probably even add a few milliseconds over head but that wouldn't be noticed with the amount of data you are inserting. If you are really concerned about perforance, reconsider the use of REPLACE

> 
> REPLACE works exactly like INSERT, except that if an old row in the
>  table has the same value as a new row for a PRIMARY KEY or a UNIQUE
>  index, the old row is deleted before the new row is inserted.
> 
> 
> 

This could in many situations result in the REPLACE operation being a lot slower than an [INSERT ON DUPLICATE KEY](http://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html) type query.
Yes, there is no benefit performance-wise for a query like this.

You will see the performance gain only if there will be a lot of separate insert queries inside of a transaction.