我用的是這樣的:大型文本查詢的Mysql服務器過載?
$url_title = mysql_real_escape_string($_GET['title']);
$sql = dbquery("SELECT * FROM `videos` WHERE `post_name` = '$url_title' LIMIT 0, 1");
/* or this old one
$local_id = ($_GET['id'];
$sql = dbquery("SELECT * FROM `videos` WHERE `id` = '$local_id' LIMIT 0, 1");
// for urls like :
// example.com/video/music/red-hot-chili-peppers-californication-564/
*/
$num_rows = mysql_num_rows($sql);
if ($num_rows == "0"){die();}
while($row = mysql_fetch_array($sql)){
$local_id = $row["id"]; // PRIMARY KEY ; auto increment
$video_id = $row["youtube_id"]; // Unique
$title = $row["name"]; // Unique
$name_slug = $row["name_slug"]; // Unique
// some more code
}
// and this one for urls like :
// example.com/video/music/red-hot-chili-peppers-californication/
什麼,我要問的是:
是正常的,有更大的服務器負載,當我查詢「紅熱辣椒 - 辣椒 - 加州靡情」爲例在數據庫而不是「564」?
所有字段的類型都是varchar,除了$ id,其值是int。
你的桌子上有什麼指標? – 2011-12-27 17:18:05
我編輯了帖子。 – m3tsys 2011-12-27 21:32:28
但桌上有什麼指標?如果在標題欄上沒有索引,它將顯着變慢 – 2011-12-27 21:52:16