The only question I still ponder is how you structure your directory hierarchy containing tens of thousands of jobs so that you avoid such bulky directories?
Our job "numbers" are a letter followed by four numbers, e.g., A0000-A9999, B0000-B9999, etc. The archive directory has directories named A0, A1, A2, etc., and A0 contains all jobs that begin with those two characters. So the greatest number of possible directories in a single index would be 1000, which isn't too many to list fairly quickly. The perfect division of a large number of items in terms of balancing the directory tree and capping the number of items in a single directory would be to take the square root of the quantity and put that many items in each sub-directory, which would yield the same number of sub-directories as items within each. But if that's too many, take the cube root of the number and create one extra level, etc.