Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Read/Write vs Database Read/Write

Which is more expensive to do in terms of resources and efficiency, File read/write operation or Database Read/Write operation

like image 484
felix Avatar asked Jul 20 '10 18:07

felix


People also ask

Is writing to file faster than writing to database?

4 Answers. Show activity on this post. Database is faster.

Which is faster reading from file or database?

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. This is probably caused by better caching in MySQL database.

What is read write in databases?

In computer science, in the field of databases, read–write conflict, also known as unrepeatable reads, is a computational anomaly associated with interleaved execution of transactions. Given a schedule S. In this example, T1 has read the original value of A, and is waiting for T2 to finish.

What is database write only?

In information technology, a write-only memory (WOM) is a memory location or register that can be written to but not read. In addition to its literal meaning, the term may be applied to a situation when the data written by one circuit can be read only by other circuitry.


1 Answers

I was initially going to say database read/write, hands down, as it would include the requisite file io on top of the DB overhead, but then realized its not that simple. If you have your entire DB loaded into memory, reads would be nearly instantaneous as there's no file IO involved.

Writes would, in general, be faster too, as the DB engine doesn't have to wait for the file IO to complete before returning since they can take a "lazy write" approach.

A poorly tuned database, on the other hand, will be orders of magnitude slower than any file based IO. DB tuning matters. A lot.

like image 170
Tim Coker Avatar answered Oct 03 '22 07:10

Tim Coker