Click to See Complete Forum and Search --> : max/optimal files per directory?


NeutrinaNewt
08-07-2003, 03:22 PM
We're currently developing a huge web-based (LAMP) image catalog for a client. Although I don't know exactly how many images there will be at this point, I want to make good decisions about directory structure and filenaming conventions before starting any other development.

Can anyone out there see performance or other disadvantages to just put all the images in one big directory:

/image-store/*.*

or are there advantages to using some sort of multi-directory scheme:

/image-store/a/0/a0000.jpg
. . .
/image-store/z/9/z9999.jpg

Thanks in advance for any advice!

yelvington
08-09-2003, 09:40 PM
Yes, the latter will be faster.

Directory access is a linear search on an unsorted pile-of-stuff.

On reasonably sized directories that's not a big deal, but if you put thousands of files in a directory, performance will suffer.

If you get really anal-retentive about this issue you'll wind up with a filesystem that amounts to a sorted binary tree. But there are practical limits to path length in various Unixes (Unices?).

So just do something practical, like your example.