Feedback
Did this article resolve your question/issue?

   

Article

Remove orphaned entries from sf_chunks table in Sitefinity database

« Go Back

Information

 
TitleRemove orphaned entries from sf_chunks table in Sitefinity database
URL Nameremove-orphaned-entries-from-sf-chunks-table-in-Sitefinity-database
Article Number000183532
EnvironmentProduct: Sitefinity
Version: 9.x, 10.x, 11.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
There are orphaned binary chunks in sf_chunks table of the database. How to delete them?
Steps to Reproduce
Clarifying Information
For more details about the sf_chunks table refer to Knowledge Base article  How to reduce database size?
Error Message
Defect Number
Enhancement Number
Cause
Resolution
To check if there are any orphaned entries run the following SQL query:
 
SELECT ch.file_id 
FROM sf_chunks ch 
WHERE ch.file_id NOT IN (
SELECT mfl.file_id 
FROM sf_media_content mc
JOIN sf_media_file_links mfl 
ON mc.content_id = mfl.content_id
JOIN sf_chunks ch 
ON ch.file_id = mfl.file_id)

AND ch.file_id NOT IN (
SELECT ch.file_id 
FROM sf_media_thumbnails mt
JOIN sf_media_content mc 
ON mc.content_id = mt.content_id
JOIN sf_chunks ch 
ON mt.file_id = ch.file_id)

To delete any such entries run the query below:
 
DELETE FROM sf_chunks 
WHERE file_id IN (
SELECT ch.file_id 
FROM sf_chunks ch 
WHERE ch.file_id NOT IN (
SELECT mfl.file_id 
FROM sf_media_content mc
JOIN sf_media_file_links mfl 
ON mc.content_id = mfl.content_id
JOIN sf_chunks ch 
ON ch.file_id = mfl.file_id)

AND ch.file_id NOT IN (
SELECT ch.file_id 
FROM sf_media_thumbnails mt
JOIN sf_media_content mc 
ON mc.content_id = mt.content_id
JOIN sf_chunks ch 
ON mt.file_id = ch.file_id)
)

 
Workaround
Notes
Last Modified Date11/20/2020 7:18 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.