On Mon, 22 Jul 2002 23:09:12 -0400, you wrote: >currently I am holding all of the files in 1 directory since the DB can >keep track of them, however their number has grown to over 400 at this >point > >my issue is whether it would be worth it (performance wise) to split them >into thumbs and works thus having 200+ files per directory as opposed to >so many, I am expecting the number of images to double in the future.
As one other poster has mentioned, this is not really a PHP issue, but more of an OS one. IMHO, anytime you are dealing with a group of files that numbers more than say, 200 or so, it's worth it to split them out in seperate directories. I would suggest some sort of one or two level hash, based on the filenames. (Forget just splitting out the thumbnails, because if you really expect the number to double in the future you'll be glad you spent the extra time to put the hash into place.) If your names are sufficiently different, I would suggest hashing the directories based on the first two characters of the filename. For example, lets say you have two jpgs called: joejohnson.jpg tomsmith.jpg Place them in directories like so: /images/j/o/joejohnson.jpg /images/t/o/tomsmith.jpg This is similar to how a lot of mail delivery agents can be configured to deliver mail to a host with a lot of different users. If for some reason the filenames tend to begin with the same characters, then work backward for the hash. For example, I work at a real estate company and the photos for our listings are named off the listing number. Most of the time these numbers are in the same range, so we use the LAST two digits of the number. For example: 2450067.jpg 2450256.jpg go in /images/6/7/2450067.jpg /images/5/6/2450256.jpg Anyway, with a hash you have a definite algorithm to figure out where a file should be placed, and later where it should be retrieved. HTH... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php