When importing data into a MySQL database using a PHP script, what are key factors to consider for performance optimization?

When importing data into a MySQL database using a PHP script, key factors to consider for performance optimization include using prepared statements to prevent SQL injection, batching multiple insert queries into a single transaction, disabling auto-commit mode, and optimizing the database schema for efficient data storage.

// Connect to MySQL database
$mysqli = new mysqli("localhost", "username", "password", "database");

// Prepare insert statement
$stmt = $mysqli->prepare("INSERT INTO table_name (column1, column2) VALUES (?, ?)");

// Begin transaction
$mysqli->autocommit(FALSE);

// Loop through data and bind parameters
foreach ($data as $row) {
    $stmt->bind_param("ss", $row['value1'], $row['value2']);
    $stmt->execute();
}

// Commit transaction
$mysqli->commit();

// Close statement and connection
$stmt->close();
$mysqli->close();