开发者

PHP GLOB vs MySQL search in speed?

I have about 5,000 pictures in a folder on my site. I need to create an array to index through on every page load, so that i can shuffle() it and switch in a slide show like manner when the user clicks the "next" butto开发者_StackOverflow中文版n.

Would it be faster to run glob() in PHP in the folder every time, or create a permanent MySQL table?

And if it is faster to use MySQL, whats the best way to make the table dynamic, as I may be adding more pics to the folder over time.

Thanks all.


Generally speaking :

File retrieval is faster in file systems File search is faster in database system(MySql)

You need to keep the above two in mind but in practical scenarios caching plays an important role too, so you might not see any difference with small data sets.


Well, it depends. In certain circumstances glob() may run as fast as a SELECT query, so if you do not want to take chances, stick to MySQL.

See also: How can i optimize MySQL's ORDER BY RAND() function?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜