Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local storage: MySQL vs. JSON?

I'm working on an app that's going to be parsing, processing, and formatting a lot of data blocks (stellar position and brightness data). A single night of data can have a dozen files, each consisting of several hundred lines. I have two options for storage and access of the raw data: database (MySQL) or JSON files. This is all in a local environment, so bandwidth and request times are virtually negligible - but I don't know enough about either option to say which is optimal.

Can you, the enlightened SO community, share your knowledge as to whether or not one is the clear choice? I don't really need to fragment the data, so MySQL's relational capabilities are moot - just wondering if one is faster or more lightweight.

(Tried my best to dodge the "which is better" taboo - if I can reword or clarify, please let me know!)


EDIT: Seriously, anonymous close votes are not helpful. I'd like to learn how to form my questions better so as not to waste everyone's time - tell what I can do to change it!

like image 264
CodeMoose Avatar asked Jun 03 '13 16:06

CodeMoose


People also ask

Is it good to store JSON in MySQL?

MySQL JSON data type allows you to store JSON data such that you can easily read or search values in it using key or array index, making it really fast. There is no need to convert text to JSON or vice versa for querying data.

Is it good idea to store JSON in database?

JSON is perfect for storing temporary data that's consumed by the entity that creates the data. A good example is user-generated data such as filling out a form or information exchange between an API and an app.

Which is faster JSON or MySQL?

From the tests I did Inserting or storing data MySQL was quicker and the code is cleaner even though you still have to design the database layout and schema it's still worth it to use MySQL. Reading and fetching data JSON was quicker, i was surprised!

Should I use a database or JSON file?

A relational database makes sense for fast and efficient storage and retrieval of data that has relational properties. JSON is a great data format because it is simple, lightweight and ideal for passing around raw data in a very basic format with a syntax suited to storing and exchanging text information.


1 Answers

If you're always going to be saving and loading entire data sets, and don't need to do complex queries, JSON is probably the simpler and more efficient method. But if you really want to be sure, you should benchmark them.

There are also databases with less overhead than MySQL, such as SQLite.

like image 80
Barmar Avatar answered Oct 14 '22 07:10

Barmar