I went ahead and ran a test where one query uses a prepared statement, and the other builds the entire query then executes that. I'm probably not making what I'm wanting to know easy to understand.
Here's my test code. I was thinking prepared statements sort of held back execution until a $stmt->close() was called to optimize it or something. That doesn't appear to be the case though as the test that builds the query using real_escape_string is at least 10 times faster.
<?php
$db = new mysqli('localhost', 'user', 'pass', 'test');
$start = microtime(true);
$a = 'a';
$b = 'b';
$sql = $db->prepare('INSERT INTO multi (a,b) VALUES(?, ?)');
$sql->bind_param('ss', $a, $b);
for($i = 0; $i < 10000; $i++)
{
$a = chr($i % 1);
$b = chr($i % 2);
$sql->execute();
}
$sql->close();
/*$sql = '';
for($i = 0; $i < 10000; $i++)
{
$a = $db->real_escape_string(chr($i % 1));
$b = $db->real_escape_string(chr($i % 2));
$sql .= ",('$a','$b')";
}
$db->query('INSERT INTO multi (a,b) VALUES ' . substr($sql, 1));*/
echo microtime(true) - $start;
//$db->query('TRUNCATE TABLE multi');
$db->close();
?>