Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is file system storage faster than SQL databases

Extending this thread - I would just like to know why it's faster to retrieve files from a file system, rather than a MySQL database. If one were to benchmark the two to see which would retrieve the most data (multiple types of data) over 10 minutes - which one would win?

If a file system is truly faster, then why not just store everything in a file system and replace a database with csv or xml?

EDIT 1:

I found a good resource for alternate storage options for java

EDIT 2:

I'm looking for a Java API/Jar that has the functionality of a SQL Database Server Engine (or at least some of it) that uses XML for data storage (preferably). If you know of something, please leave a comment below.

like image 451
ThreaT Avatar asked Dec 01 '22 22:12

ThreaT


2 Answers

At the end of the day the database does just store the data in the file system. It's all the useful stuff on top of just the raw data that makes you decide to use a database.

If you can replicate the functionality, scalability, robustness, integrity, etc, etc of a database system using CSV and still make it perform faster than a relational database then yes I'd suggest doing it your way.

It'd take you a few years to get there though.

Of course, relational systems are not the only way to store data. There are object-oriented database systems (db4o, InterSystems Cache) and document-based systems (RavenDB).

Performance is also relative to the style and volume of data you are working with and what you intend to do with it - I'm not going to even try and discuss that, it's too open ended.

I will also not start the follow on discussion: if memory is truly faster than the file system, why not just store everything in memory? :-)

This also seems similar to another question I answered a long while ago:

Is C# really slower than say C++?

Basically stuff isn't always done just for performance.

like image 125
Adam Houldsworth Avatar answered Dec 16 '22 10:12

Adam Houldsworth


MySQL uses the file system the same as everything else on a computer. To retrieve a single piece of data, or a table of data, there is no faster way that directly from the file system. MySQL would just be a small bit of overhead added to that file system pull.

If you need to do some intelligent selecting, match some rows, or filter that data, MySQL is going to do that faster than most other options. The database server provides you calculation and data manipulation power that a filesystem can't.

like image 37
whiteatom Avatar answered Dec 16 '22 11:12

whiteatom