nop 2.7 Picture table still too big - after setting to store to file

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi all,
Pictures are stored into...:  changed to File under Media Settings (I have nopcommerce 2.7)
But I did this after a month of development and all previous pics are still in DB
That table is 4 GB still, even though my setting in now set to store in File system.
How can I now reduce the size of the Picture table?
Do you guys have a script? I assume any new pics get uploaded go to file system, correct?
What about the data that was there before I changed setting?
Please help
Thanks
James
11 years ago
no answer yet - anyone on nopcommerce team can help?
11 years ago
jamescasas wrote:
What about the data that was there before I changed setting?

They are also moved to the file system

jamescasas wrote:
That table is 4 GB still

Try executing the following SQL command over your database
DBCC SHRINKDATABASE('your_database_name')
GO
11 years ago
ty but that did not work.
The issue is I uploaded 10,000+ products with images.
Now after categorizing, I am only using 2000+ products/images.
So that means I don't need 8000 images in that Picture table
DBCC shrinkfile wont' help
Perhaps a query to tell me which images are not being used anywhere would help so I can delete those by script?
But i need to know what that script is?
11 years ago
You would need to do a left join against

Product_Picture_Mapping
ProductVariant
Category

I think those are the only 3 tables.  I will write a quick script in an hour or so because that's something I've wanted to do as well.
11 years ago

SELECT p.Id
FROM Picture p
LEFT JOIN Product_Picture_Mapping ppm
  ON ppm.PictureId = p.Id
LEFT JOIN ProductVariant pv
  ON pv.PictureId = p.Id
LEFT JOIN Category c
  ON c.PictureId = p.Id
WHERE ppm.Id IS NULL
  AND pv.Id IS NULL
  AND c.Id IS NULL


This should give you the rows in Picture that are not associated to anything else and should be safe to delete.  If there is another table that uses Picture that I didn't include, you'll delete it's pictures so make sure you back up your database first.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.