Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is faster, flat files or a MySQL RAM database?

I need a simple way for multiple running PHP scripts to share data.

Should I create a MySQL DB with a RAM storage engine, and share data via that (can multiple scripts connect to the same DB simultaneously?)

Or would flat files with one piece of data per line be better?

like image 354
Robin Rodricks Avatar asked Sep 17 '09 18:09

Robin Rodricks


People also ask

Is flat file faster than database?

For the standard operations (view, edit, page revisions), holding the information in flat files is clearly faster than accessing them in a database, and with page caching abilities (coming soon) it'll be even faster.

Which is faster file or database?

31-20. We can see that reading data from MySQL is not always slower than reading data from pure filesystem. Especially in the case when small files are read first time, MySQL database is much faster than a pure filesystem.

Is MySQL the fastest database?

Ultimately, speed will depend on the way you're using the database. PostgreSQL is known to be faster for handling massive data sets, complicated queries, and read-write operations. Meanwhile, MySQL is known to be faster with read-only commands.

What is the best reason to use a flat file instead of a database?

They Require Fewer Hardware and Software Components. There's a good reason many operating systems, such as Windows, Macintosh, and Linux, use flat file databases. Though the databases can become bogged down with several thousand records, they are usually more efficient than other options.


1 Answers

Flat files? Nooooooo...

Use a good DB engine (MySQL, SQLite, etc). Then, for maximum performance, use memcached to cache content.


In this way, you have the ease and reliability of sharing data between processes using proven server software that handles concurrency, etc... But you get the speed of having your data cached.

Keep in mind a couple things:

  1. MySQL has a query cache. If you are issuing the same queries repeteadly, you can gain a lot of performance without adding a caching layer.
  2. MySQL is really fast anyway. Have you load-tested to demonstrate it is not fast enough?
like image 120
gahooa Avatar answered Oct 10 '22 21:10

gahooa