Search code examples
phpmysqlload

MySQL server overload with large text query?


I use something like this:

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

What I want to ask is:

Is it normal to have bigger server loads when I query "red-hot-chili-peppers-californication" for example in the db instead of "564" ?

The type of all the fields is varchar except for $id which is int.


Solution

  • I assume this is normal. It is easier to compare numbers than comparing strings. In every programming language.