A similar approach worked fine for me back in the old dark ages of DOS and 8.3 file names. FAT-16 dealt pretty badly with huge (meaining over 2000 files, I didn't have to deal with 400k files) subdirectories.

There probably IS a better way. But is it worth it?

I'd suggest you set up a simple isolation layer, so you can do

$fh=image_open("123456.jpg");
Then run some tests with; it should be easy to create a sample 400k file subtree with something like the right distribution of file sizes, if you have the file space.

If it's fast enough, then don't worry about it. If you have a performance issue, then worry about making it better.

Offhand, I suspect if you have a performance issue, it will come from the horrible impact this kind of structure will have on your disk caching, since accessing any given file is going to involve reading 4 directories then the file, and your images may not be accessed in any kind of cache-friendly order.

If it turns out the performance bites, you can change your open routine to use some other underlying structure without affecting the rest of the code...


Mike

In reply to Re: Need directory scheme to store 400,000 images by RMGir
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.