Is image storage path or binary in the database? Advantages and disadvantages

Source: Internet
Author: User
Maybe someone immediately says the storage path when this problem is thrown out. But think about this problem. If the path is stored, you can only store one path in the database or cache, and the call is a file call. When there are a lot of project images, isn't it very significant? If the binary file is stored, some people immediately say that the path is stored when this problem is thrown out.
But think about this problem. If the path is stored, you can only store one path in the database or cache, and the call is a file call. When there are a lot of project images, isn't it very significant?
If binary data is saved, the image data can be directly converted to binary data and stored in the database and cache. You can directly convert it
Which one is better? Why do people talk about storage paths? Is the binary conversion algorithm especially expensive?

Reply content:

Maybe someone immediately says the storage path when this problem is thrown out.
But think about this problem. If the path is stored, you can only store one path in the database or cache, and the call is a file call. When there are a lot of project images, isn't it very significant?
If binary data is saved, the image data can be directly converted to binary data and stored in the database and cache. You can directly convert it
Which one is better? Why do people talk about storage paths? Is the binary conversion algorithm especially expensive?

1. The database is not only stored but also queried. I think you should not query the binary data. storing a large field in the database affects the database performance overhead.
2. The bottom layer of the database is also file storage. Storing binary files in the database is more computing or io than directly storing them on the file system. (The original answer is more io, considering data compression and optimization during database storage, change the original answer .)
3. As a static file, image files are basically I/O operations when being read by web servers and other applications, and additional computing is required when stored in the database.
4. If you think there are many files, you can try to store them in folders, such as by the first letter, by user ID, or using cdn, which is better than storing them in a database.

Http://www.cnblogs.com/wangtao_20/p/3440570.html

Http://www.oschina.net/question/253614_78251

You are right. When there are a large number of files, the default file system will significantly affect the speed, this is mainly because the default file system is not designed for the storage of a large number of files. Without a path index, the efficiency of files will be exponentially reduced.
But it cannot be simply stored into the database as other data. It is best to store the file database separately and process it separately, because file requests are generally pure I/O operations, there is no need for complex logic and program processing. It is best to open up channels separately to allow requests to bypass the server program and reduce the burden on the server program.
In addition, you can consider databases specially designed for files, such as gridfs of mongodb.

The database runs multiple pointers and expands the memory space! Besides, a server application must consider balancing bus and IO! File storage costs are relatively lower, including development costs and expansion costs!

"When there are a lot of project images," database query should be a bottleneck. If it is really large, it is usually placed under the second-level domain name, isolated from the main site, or use third-party services.
Higher scalability of stored URLs, including review, backup, and use of third-party services.

Boss said, Mr. Wang, the relevant department said that our images are unhealthy. You can check them for us. It takes a lot of effort to store databases.
Boss said, Mr. Wang, we need to expand several servers. You can give us a full picture. It takes a lot of effort to store databases.
Boss said, Mr. Wang, we have cooperated with qiniu/and put our pictures on them. It takes a lot of effort to store databases.

My opinion above.

304 Not modified. Is this reason strong enough? How can you prove it if it is stored in the database? Add another version, like/getfile. php? Key = dassafs23fdsa & v = 20150109231820? But it is inevitable that additional database queries are required for verification?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.