Re: Re: [BULK] Re: [PHP] OK to have many files in one folder?
| From: | Jim Lucas | Date: | Mon, 18 Jun 2007 15:41:57 +0000 |
| Subject: | Re: Re: [BULK] Re: [PHP] OK to have many files in one folder? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257316@lists.php.net to get a copy of this message | ||
Daniel Brown wrote:
On 6/18/07, Tijnema <tijnema@gmail.com> wrote:and the fact that a lot of hosting environments have a DB on a different machine. This would make for a much worse performance then the local filesystem. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William ShakespeareOn 6/18/07, Daniel Brown <parasane@gmail.com> wrote:On 6/18/07, Tijnema <tijnema@gmail.com> wrote:On 6/18/07, Daniel Brown <parasane@gmail.com> wrote:Do I have benchmarks? No. Do I have the time to do them now? No. Do I feel confident enough that if you were to run those benchmark tests that it would prove me right? Damn straight. ;-P -- Daniel P. BrownOn 6/18/07, Colin Guthrie <gmane@colin.guthr.ie> wrote:store themclive wrote:I have no clue how big the files are, but you might want tohow much ;)in a database. That can speed up things, but don't ask mefaster, I meanno dude, while database are convenient, files systems areTijnemadirectories.thats what they were designed for, serving files. For lots of files I would store them in directories and subgive 255Yeah amen! I generally use a two character hex hash in my main folder toa databasesub folders each containing files. In my case the hash is calculated from some known info - e.g.filesID and then stored in a meta data table. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpTij, Referring to one of my earlier posts in this thread, as a refresher, database information is stored in files. So to storein a database means the following has to take place:database file.1.) Data is uploaded to the server. 2.) Data is processed by the database server. 3.) Data is compressed and encrypted. 4.) Data is written to disk. (4b. - optional) Data file is checked for integrity andcorrectness of write. Then, to serve the content, a similar reverse occurs:1.) Request is sent to the server via a script. 2.) The script interfaces with the database to locate thedesired data row.3.) Once located, the data is pulled in raw form from the4.) The data is then decompressed and decrypted. 5.) The data is streamed back to the script. 6.) The script decides how to handle it, based uponhard-coded options.For a filesystem, it's simpler. Uploading:to archive.1.) Data is uploaded. 2.) Data is written to disk.Serving:1.) Request is sent via script, FTP, socket connection, orlocal request.2.) File is served through via the method requested.So there are several pros and cons for each, but just to list three of each with regard to database storage: Pros:Can be stored centralized and portable, without needingAutomatically encrypted and compressed upon storage. Easier and faster to search. Cons:How sure are you about all this? Benchmarks? What about search time for the harddrives etc? It needs to scan the inode table to find the file, etc.., then it needs to locate that file on the harddrive, while the second file might be on the other side of the disk.... Storing all files in one single filesystem means you have only 1 inode :) All data is stored at same place (atleast, it should be) TijnemaSlower storage and retrieval Much greater risk of corruption Not always cross-compatible across platforms, versions,installations, etc. -- Daniel P. BrownI think I have some time to write a simple script in a few hours, I'd like to see what the performance difference is :) TijnemaWell, keep in mind that I don't expect that you'd see much difference at all with a single file, but try doing multiple files of ASCII and binary, various sizes, and also several simultaneous connections. Two other things I forgot to mention with database storage are a pro and con, respectively - caching and accessibility.