I'll note that what I've seen before is more along these lines:
1/2/3/123.jpg 8/6/7/8675309.jpg
That is, not repeating the whole prefix up that point. You can then easily turn a simple filename into a file-and-directory thing with this:
my $fullpath = $file; # Not just the number, but e.g. "7893.jpg" $fullpath =~ s|(\w{1,3}).*|join('/',split(//,$1),$&)|e or die "Bad filename $file";
(adjust the "3" to a deeper directory hierarchy as desired). This will put a short filename - like 12.jpg - into a higher level directory than the other files (12.jpg becomes 1/2/12.jpg); if that's not desired, consider using a filename like 00000012.jpg instead of 12.jpg.

On a small scale (1 initial letter), this is the way the terminfo database files are stored, and is also pretty much how Debian organizes their packages on their ftp sites.

But I'd personally go with the ReiserFS suggestion myself, assuming you have full control of the target box.


In reply to Re: Need directory scheme to store 400,000 images by fizbin
in thread Need directory scheme to store 400,000 images by markjugg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.