Is it more efficient to store files flat or in folders?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it more efficient to store files flat or in folders?
Hello...
I have a folder in which I store letters that I have written, creatively called 'letters'. Within this folder I have more folders for each person or company that I communicate with, which obviously contain the relevant files/letters.
I have however, over the last number of months, started to ignore this folder structure and have begun to store letters directly within the letters folder without dropping them into sub-folders.
In order to make this manageable I have changed how I name files and now employ a specific naming routine... in the case of letters, I use the following naming convention:
This method of a more-or-less flat file structure seems very natural to me.
Taking this to extremes this could result in a single partition having say 100,000 files stored flatly instead of within a hundred (for arguments sake) or so folders/directories.
The question is, is a flat file structure less, equally, or more efficient than a directory based structure, putting aside the delay that would occur as a graphical file manager attempts to display the contents of a flat structure with so many files?
Any thoughts on the efficiency and any pros and cons would be very welcome.
It depends quite a bit on which filesystem you are using. EXT2/3 in general don't perform as well with (very) large numbers of files as more advanced filesystems like XFS and JFS; ReiserFS specifically is supposed to be very good with large directory trees comprised of many small files.
That said, 100K files isn't really a lot in the grand scheme of things; there are mail servers out there which are storing many times that number of files. All of the filesystems should be able to cope with that number, and the real world performance impact will likely be very small. I would still look into using XFS or ReiserFS, but that is more personal taste than anything.
If i am not mistaken, putting files into folders simply means that the file entries have codes added to associate them with directories (folders)---which are actually files themselves. The associaton of files with folders does not affect how much space is used.
I would organize thing into folders based on what make you most efficient on the user side.
I would organize thing into folders based on what make you most efficient on the user side.
Bingo.
I also tend to place like files in single folders, and name them in such a manner that I can type 3-4 characters into my file browser and quickly find the file I want. I find that this method is the fastest and most efficient for me.
The main performance bottleneck may be whatever you're using to browse the files. While the file system driver may have no particular issues with thousands of files in one directory, your file browser might bog down.
This can be a particularly annoying performance issue if you're browsing over a network or over the internet.
Possibly 100,000 loose files of different written letters and papers you've created over time? If I were you, I'd probably create me a database of these in MySQL or PostgreSQL, maybe SQLite even to organize these and to access them.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.