In what scenarios would it be best practice to utilize the LIMIT clause when working with MySQL data in PHP?

When working with MySQL data in PHP, it is best practice to utilize the LIMIT clause when you only need to retrieve a specific number of rows from a query result. This can help optimize performance by reducing the amount of data fetched from the database.

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

// Select data with LIMIT clause
$query = "SELECT * FROM table_name LIMIT 10";
$result = $mysqli->query($query);

// Fetch and display results
while ($row = $result->fetch_assoc()) {
    echo $row['column_name'] . "<br>";
}

// Close database connection
$mysqli->close();