我想知道關於螢火蟲的一些事情, 當我嘗試使用螢火蟲開放載入一個頁面時,它開始時間線。Firebug&Performance Question?
是什麼:
等待, reciving, DomContentLoaded, 負載,
的MySQL查詢從列表中有什麼影響?我看到更多的mysql查詢,我正在增加,reciving部分正在增加。
讓我粘貼我在覈心上使用的請求,以生成動態鏈接或內容。
function getContent($id = '') {
$id = mysql_real_escape_string ($id);
$sql = 'SELECT id,post_title,post_content FROM wp_posts WHERE post_category="67" ORDER BY post_date DESC LIMIT 1';
$res = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($res) !=0):
while ($row = mysql_fetch_assoc($res)) {
// this remove caption from wordpress, get 450 words to be used for exerpt, encode html,
$mycontent = $row['post_content'];
$mycontent = strip_tags($mycontent);
$mycontent = substr($mycontent,0,250);
$mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent);
$mycontent = htmlentities($mycontent);
//encode the words for html
$title = $row['post_title'];
$title = htmlentities($title);
echo '
<<h1><a href="single.php?id='.$row['id'].'">'.$title.'</a> </h1>
<div class="cssclass"> '.$mycontent.' </div>
'; //echo
}
else:
echo 'This page dosnt exist.';
endif;
} // end
這段代碼或它的正常情況是錯誤的,我的db是大約75.000行。
感謝您閱讀本文。
這個問題更多的是關於服務器端的性能,而不是關於Firebug。 – Teddy
請仔細閱讀第一部分,謝謝 – AvinD
刪除67左右的引號(如果post_category在數據庫的整數字段中),隱式轉換有時會傷害性能。確保你有索引(post_category,post_date) - 這是滿足給定查詢的最佳選擇。爲了防止sql注入,如果post_category是整數,則將$ id轉換爲整數或使用準備好的語句。 –