We have about half a million images residing in the file system. Multiple images belong to a product and named after ProductID. For example, Product ID 10010 has 3 images; 10010_1.jpg, 10010_2.jpg and 10010_3.jpg. To display these 3 images in photo gallery, current code in classic ASP is querying the file system. The code looks something like this:
Dim objFSO, i
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
i=1
While objFSO.FileExists(Server.MapPath(productid & "_" & i & ".jpg")
' draw the image
i = i + 1
WEnd
Isn’t it better idea to keep the image names in a database table and run a query to get the list of images available for a given product? I am pretty sure that reading it from the database is better. Just reluctant because I need a big table with half million records. Which way is more efficient?
My table will look something like this:
ID ProductID ImageURL
-------------------------------------------
1 10010 10010_1.jpg
2 10010 10010_2.jpg
3 10010 10010_3.jpg
4 10011 10011_1.jpg
. . .
Any suggestions? I am re-writing the web site in ASP .NET MVC 3. Anything extra I need to take care of in this platform/Framework?
Half a million records in a database is not really that big.
If your table is indexed correctly then you will get far better performance from a database than the file system.