LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
LinkBack Search this Thread
Old 03-10-2008, 02:58 PM   #1
dman65
Member
 
Registered: Sep 2003
Posts: 61

Rep: Reputation: 15
Best way to organize large numbers of files.


I have an application where a large number of files have to be stored on a server for reference purposes. These documents are named from 00000000 to 99999999. Currently there are only 2 million documents, but the count is increasing.

Storing all of these in one single directory seems to be relatively slow and occasionally I have noticed some entries simply disappearing. I always have a backup so putting them back in place is not a problem, but I don't like to have them disappear.

I am wondering if anyone knows what the best way to store these documents in the file system is. I need to have a balance between quick access, stability (nothing spontaneously disappearing), and ease of backup.

In a situation like this is it more efficient to create a directory hierarchy of say:

/1/2/3/4/5/12345678 for storing document number 12345678? If this is efficient is there a certain hierarchy point to stop for efficiency purposes? For instance is:
/1/2/3/4/5/12345678 better, worse, or no different from
/1/2/3/5/5/6/12345678

Thanks for any input.
 
Old 03-10-2008, 03:42 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Squeeze, Fedora 14
Posts: 7,268

Rep: Reputation: 83
In order to balance the number of files per directory it would be better to number the directories by the least significant digit. For example file 12345678 should be in directory /8/7/6.

------------------
Steve Stites
 
Old 03-12-2008, 06:17 PM   #3
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 954

Rep: Reputation: 34
for that many i would split into say 100 dirs based on

12345678%100

(ie the last 2 digits)
so that one would be
/78/12345678

or 1000 dirs

/678/12345678

i cant see how many levels woudl be more efficiant,
all it would do is eat up your inodes

Last edited by dasy2k1; 03-12-2008 at 06:19 PM.
 
Old 03-12-2008, 07:28 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.2, Centos 5.8
Posts: 11,729

Rep: Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902
I'd go
/123456/12345678
or
/12345/123454678

it's less confusing to people if you use the leading nums as the dir
 
Old 03-12-2008, 07:42 PM   #5
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 954

Rep: Reputation: 34
that is true,
but that way provided that they are generated in sequential order the lower directorys fill up first.

of you sort by the last numbers then the directory load is ballanced
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning large numbers of IPv6 addresses jack_sprat Linux - Networking 0 10-03-2007 06:44 PM
Organize source files in Kdevelop lbdgwgt Programming 1 08-30-2007 03:03 PM
LXer: Using 'ls' and 'xargs' to manage large numbers of files LXer Syndicated Linux News 0 02-15-2007 06:16 AM
changing SOAs in named with large numbers of zone files untoldone Linux - Networking 3 08-17-2004 02:35 PM
Organize my mp3-files Soubi Linux - Software 11 03-16-2003 10:08 PM


All times are GMT -5. The time now is 06:58 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration