开发者

PHP MySQL Stored Procedures still slow to output (almost crashes browser)

Hi I asked a question on here a couple of weeks ago about speeding up mysql output for my db of about 5000 records. I used the advice to use ob_start() and stored procedures. However its still almost crashing the browser and being extremely slow to output the records, any ideas how to optimise this:

    ob_start();
    $conn = new Mysqli("xxxxxxxxxx", "xxxxxxxxx", "xxxxxxxxx", "xxxxxxxxxx");

    $result = $conn->query(sprintf("call list_products(%d)", 6000));

    while($row = $result->fetch_assoc()){
        echo "<tr>";
        echo "<td>" . $row['xxxxxxx'] . "</td>";
        echo "<td>" . $row['xxxxx'] . "</td>";
        echo "<td>" . $row['xxxxx'] . "</td>";
        echo "<td>" . $row['xxxxxx'] . "<开发者_如何学JAVA;/td>";
        echo "<td>" . $row['xxxx'] . "</td>";
        echo "<td>" . $row['xxx'] . "</td>";
        echo "<td>" . $row['xx'] . "</td>";
        echo "<td>" . $row['xxxx'] . "</td>";
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";

    $result->close();   
    $conn->close();

    ob_end_flush();


using ob isn't good at all whoever said that have misinformed you... what you should do isn't to much about how you're outputting your data but look in to your mysql query and how you could optimize it as possible, using key columns to find whatever you looping, try to limit the rows as much as possible, using index all of these has great importance when you want to optimize your database script

You can use the EXPLAIN word to find out where the bottleneck might be, where you might need to index and so on

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜