我的视频ID超过46,000,将使用我的数据库记录(大约10,000)进行搜索。 如果存在则该id将存储在数组中

I have video id more than 46,000 which will be searching with my database records (about 10,000). If exist then this id will be stored in a array . I have created a php script to do that but it is take more than 50sec and with a high pressure on my laptop running WAMP. I think there are many algorithm on searching to do such work. I want to know if there any alternative faster way to do that. My code is attached below. Thanks

$query = "SELECT video_id,title FROM `all_videos`";
$res = mysql_query($query);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
while ($row = mysql_fetch_row($res)) {
    $b = array_search($row[0], $arr);  // Searching video id from $arr - array..
    if ($b != '' or $b === 0) // Matching..
    {
        echo 'Match Found!! => ' . $row[0] . ' || ' . $row[1] . '<hr>';
        $del[$i] = $row[0];
        $i++;
    }

}