开发者

Would implementing files (all types: audio, video, text, etc.) as database tables and their content as their rows be worthwile?

Consider I modify the way files are stored in a system, where every file name would actually be the table name in a database and each line in the file would actually be the rows of that table. Would that increase overall system speed? would it be worthwhile? what are the tradeoffs?

To further clarify the distinction between this and the normal use o开发者_Go百科f a database, consider the files not to simply be text files, but also audio, video, binary, etc. where they are stored in the manner mentioned in the previous paragraph.

Immediate benefits that I can see from this is that i can read/write any line from/to a file without having to repeatedly read/write the previous lines until reaching the desired line. Another benefit would be simultaneous reading/writing of files.

Please do not confuse this with a database file system, this is a file implementation


To add to your benefit of reading writing by location, the additional benefit are.

Pros

Indexing

Indexing the text with full text indexing that can give searching benefits. Ofcourse the size of database will probably be more then the conventional file sizes. But you have benefit in terms of performance because database system will have only one file handle open, and it will do caching and will improve performance and cause less fragmentation.

Lock/Performance

Opening/closing multiple files will put little more overhead in terms of performance because each open/close requires access control check and locking.

Replication

Replication benefits, if you put them in mysql, mysql replication is easy to setup and you can keep multiple backups easily.

Maintanence

Transfering, maintaining and querying database will be much easier then in terms of files.

Cons

File Browser Access

You can not access files through explorer or normal file system api, you will need some sort of access api probably REST based api or some viewer that can read the database.

You can check my blog about more detailed analysis.


Maybe some benefits on speed are present, but there's a lot of issue which make the cons overwhelm the pros.

  • No easy way to support Transactions
  • No easy way to support typification of fields (think about a file with BLOB objects in it)
  • Relationship constraint
  • No trivial support for cache, accessing RAM is faster than accessing disk
  • No easy way to support something like "ALTER TABLE"

I guess that if you write something which support all this kind of issues you've written a sql engine...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜