简体   繁体   中英

How do I store and call 500k images?

I have 500k unique images in my folder/directory. I want call it by name and all names are stored in Mysql database. but I heard that images can be stored in a database. So my question is which is more fastest option to display image faster. do I need to store in mySQl or can I keep same method which I am following?

If I need to store in mySQL then how do I create a table for it, and how do I store all these images?

This has been answered quite a few times. But you haven't talked about what type of application that you are building, if you are building a web application then storing the images on the file system has advantages re: caching.

Storing Images In Filesystem As Files Or In BLOB Database Field As Binaries

Storing Images in DB - Yea or Nay?

It's easy enough to store the images in a table, I would definitely avoid it though if your images are quite large.

I do not think 500k entries in a single directory will go over very well: How many files can I put in a directory?

Once upon a time, Linux ext3 started running slowly for very simple operations once a directory accumulated around 2000 files. (O(N) sorts of slowly!) After the htree patches were merged, large directory performance improved drastically, but I'd still recommend partitioning your image store based on some very easy criteria. (Squid web cache, for example, creates directory trees like 01/ , 02/ , and places files based on the first two characters in the filename.)

Do not store so many data in a db like mysql especially if you are not so familiar like you sound. Keep the images on the fs

I have 500k unique images in my folder/directory. I want call it by name and all names are stored in Mysql database. but I heard that images can be store in database. so my question is which is more fastest option to display image faster.

You should use the file system. Storing in database is not going to work very well. You should read Facebook Photo Storage Architecture to learn how facebook does it. They have the most photos in the world.

Haystack file storage:

在此处输入图片说明

Also interesting: http://www.fredberinger.com/high-performance-at-massive-scale-lessons-learned-at-facebook/

Storing images into the database (in a blob datatype) in much more inefficient than keep those images stored on the file system.

BTW here is explained how to insert binary data into a mysql table

如果您有Redis,可以将所有图像存储在内存中,这是最快的方法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM