gpt4 book ai didi

php - MySQL 服务器因大文本查询而过载?

转载 作者:行者123 更新时间:2023-11-29 06:12:00 26 4
gpt4 key购买 nike

我使用这样的东西:

    $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/

我想问的是:

当我在数据库中查询“red-hot-chili-peppers-californication”而不是“564”时,服务器负载更大是否正常?

除 $id 为 int 外,所有字段的类型均为 varchar。

最佳答案

我认为这是正常的。比较数字比比较字符串更容易。在每种编程语言中。

关于php - MySQL 服务器因大文本查询而过载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8647184/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com