Saving images: files or blobs?

后端 未结 11 2251
暖寄归人
暖寄归人 2020-11-30 07:59

When you save your images (supose you have lots of them) do you store then as blobs in your Database, or as files? Why?

Duplicate of: Storing Images in DB -

11条回答
  •  被撕碎了的回忆
    2020-11-30 08:10

    I've tried to use the db (SQL Server and MySQL) to store medium (< 5mb) files, and what I got was tons of trouble.

    1) Some DBs (SQL Server Express) have size limits;

    2) Some DBs (MySQL) become mortally slow;

    3) When you have to display a list of object, if you inadvertedly do SELECT * FROM table, tons of data will try to go up and down from the db, resulting in a deadly slow response or memory fail;

    4) Some frontends (ruby ActiveRecord) have very big troubles handling blobs.

    Just use files. Don't store them all in the same directory, use some technique to put them on several dirs (for instance, you could use last two chars of a GUID or last two digits of an int id) and then store the path on db.

提交回复
热议问题