Создаём 200к файлов:
#!/bin/bash
dir="/test"
ctr=1
range=30000
while [  ${ctr} -lt 200001 ]; do
	id=${RANDOM}
	let "id %= ${range}"
	`touch "${dir}/${id}_${ctr}.jpg"`
	let ctr=ctr+1 
done
Проверяем:
~> ./test_glob
~> ls -1 /test | wc -l
200000
Тестируем производительность:
<?php
$dir = '/test/';
$id = rand( 1, 30000 );
$pattern = $dir . $id . '_*.jpg';
$time_start = microtime(true);
$photos = glob( $pattern );
$time_end = microtime(true);
$time = $time_end - $time_start;
echo 'execution time is ', $time, ' seconds', PHP_EOL;
print_r($photos);
~> php ./test_glob.php 
execution time is 0.15708804130554 seconds
Array
(
    [0] => /test/23513_10050.jpg
    [1] => /test/23513_10631.jpg
    [2] => /test/23513_121888.jpg
    [3] => /test/23513_150044.jpg
    [4] => /test/23513_167985.jpg
    [5] => /test/23513_185798.jpg
    [6] => /test/23513_188480.jpg
    [7] => /test/23513_193143.jpg
    [8] => /test/23513_68603.jpg
)
Делаем выводы.