Search code examples
phpmysqlstreamingblobbandwidth

Is it faster to stream a picture from FS or stream it from a BLOB?


Is it faster to stream a picture/image from a file system or to stream it from a BLOB, from a MySQL database?

What I am acctually asking:

Will it be faster for PHP to read a picture from a table and output it to a browser, or to stream it directly from a file system?


Solution

  • First of all: It will in most cases be faster to read it from the file system.

    Everything starting with "First of all" needs either a "but" or an "additionally" - I'll try to provide both:

    • Additionally you will make your other queries slower, by using buffer pages for BLOB data, that could otherwise be used for data or indices.

    • But if you scale up to a more-than-one-server architecture, you will need a shared file system, which is a minefield in its own right. This sometimes (in special use cases, not routinely), is the argument that swings the jury towards storing BLOBS