Just wonder if the function mysqli_multi_query connect just 1 time开发者_如何学Python to the database or each query?
Yes because it uses $link as connection id http://php.net/manual/en/mysqli.multi-query.php
And it doesn't actually connect - it only uses already established connection.
mysqli_multiple_query
is more faster then normal query.
A small benchmark:
for ($i=0; $i<1000; $i++) {
// 3 queries, each one searching different tables over 1.000.000 records.
};
Results:
mysqli_query: 15.46s
mysqli_multi_query: 13.40s
精彩评论