in reply to is it possible to have too many files

It depends on the file system. If possible, you may want to break it down into a couple of directory levels.

Let's assume that your key column is a 4 digit number (0000-9999) - if you store 100 files in a directory, you would store the files for key 1200-1299 in 1/12/$key.

Update: It is possible that the file system is already a database (IIRC, BeOS had something like this), in which case, you may not have a problem with a large directory. I think that this is typically not the case.

Update 2: See also Re: Efficient processing of large directory, another node that references qmail's use of multi-level directories for its queuing system, and the reasoning behind it.

Update 3: Fixed big-oh of calculations. Thanks JavaFan.

--MidLifeXis

  • Comment on Re: is it possible to have too many files

Replies are listed 'Best First'.
Re^2: is it possible to have too many files
by JavaFan (Canon) on Jan 21, 2011 at 15:57 UTC
    If you break this down into one or two additional levels of subdirectories, it can become a log(N) function instead.
    With one layer of subdirectories, it'll become the square root of N. With two layers, it'll become the fourth root of N.

    You'd need Ω(log N) layers of directories to bring it down to O(log N) search time.

      Fixed. Thanks.

      --MidLifeXis