17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: <strong>FILESTREAM</strong> Database Administration<strong>FILESTREAM</strong> and Garbage Files<strong>SQL</strong> <strong>Server</strong> does not support in-place updates <strong>of</strong> the disk file storing the BLOB data for a<strong>FILESTREAM</strong> column. A disk file is created for every non-NULL <strong>FILESTREAM</strong> data valuestored in every <strong>FILESTREAM</strong> column <strong>of</strong> every table in the database. When you updatethe BLOB value stored in a <strong>FILESTREAM</strong> cell, the associated disk file also needs to beupdated. What <strong>SQL</strong> <strong>Server</strong> does internally is to create a new file with the modified value.<strong>The</strong> old version <strong>of</strong> the file will lie around in the folder until the file is no longer needed.Unwanted files are later deleted by an asynchronous garbage collection process that runsin the background. An old version <strong>of</strong> a <strong>FILESTREAM</strong> data file is available for garbagecollection when a database CHECKPOINT occurs after the transaction log is truncated pastthe LSN (Log Sequence Number) which generated the new file.For this reason, <strong>FILESTREAM</strong> storage is not ideal for cases where the BLOB data storedin the <strong>FILESTREAM</strong> column is frequently updated. Every time the <strong>FILESTREAM</strong> valueis updated (from a non-NULL value to another non-NULL value) <strong>SQL</strong> <strong>Server</strong> will haveto create a new file with the modified value. If the frequency <strong>of</strong> such update operationsis high, you might experience severe performance problems. In such a case, storing theBLOB data in the file system and storing the path to the disk file in a table might be moreefficient than using a <strong>FILESTREAM</strong> column.Garbage files and recovery modelsUnder the SIMPLE recovery model, the <strong>FILESTREAM</strong> garbage collector is triggered whena database CHECKPOINT occurs. You can issue a CHECKPOINT to trigger the garbagecollection thread to clean up the unwanted files in the <strong>FILESTREAM</strong> data container.Under the FULL and BULK_LOGGED recovery models, you might notice that issuing aCHECKPOINT does not clean up the unwanted files in the <strong>FILESTREAM</strong> data container.A CHECKPOINT may still run the garbage collector, but it may not remove the file as youwould normally expect. This is because the transaction log virtual log file (VLF) that279

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!