You seem fairly convinced that a database is not the right answer here. I'll take your word for it.

You'll definitely need to go multilevel for that many entries, even if no (human) user ever enters or does an 'ls' on the directory. Opening a file in the directory still requires finding the file and doing four searches through a few thousand files each is going to be a hell of a lot faster than doing one search through a couple million unless the names are indexed specifically for searches in a way that filesystems generally don't do.

Also, since it hasn't been mentioned yet, and I realize you may have thought of this already, but... inodes. Unless you've specifically tuned your fs to have a higher-than-default inode density, it may not be able to support 3 million files regardless of how large or small those files may be or how they're organized. 'df -i' will tell you how many inodes the filesystem has. (Why, yes, I have had a print server grind to a halt, claiming the fs was full when 2/3 of the space was unused. How did you guess? CUPS had been forgetting to clean up after itself and consumed all available inodes with 0-byte files.)


In reply to Re: (OT) should i limit number of files in a directory by dsheroh
in thread (OT) should i limit number of files in a directory by leocharre

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.