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 12: Planning, Configuration and Best PracticesBest Practices for <strong>FILESTREAM</strong> DevelopmentIn this section, we have included all best practices for developers working with<strong>FILESTREAM</strong>. Some <strong>of</strong> these practices are found in other chapters <strong>of</strong> the text as well, butthis section may provide value for quickly evaluating an application's design or for useduring a code review.Use <strong>FILESTREAM</strong> streaming APIs to read and write<strong>FILESTREAM</strong> dataAs we have seen, reading and writing <strong>FILESTREAM</strong> data using T-<strong>SQL</strong> is not efficientin most cases because, when <strong>FILESTREAM</strong> data is accessed using T-<strong>SQL</strong>, streamingcapability is not available. In addition, T-<strong>SQL</strong> access uses <strong>SQL</strong> <strong>Server</strong>'s memory forbuffering the <strong>FILESTREAM</strong> data, which can significantly add to the memory pressureon the server.For best performance, always use the Win32 or Managed API for reading and writing<strong>FILESTREAM</strong> data.Avoid small partial updates<strong>FILESTREAM</strong> does not support in-place update <strong>of</strong> the BLOB data. When you modify a<strong>FILESTREAM</strong> value, <strong>SQL</strong> <strong>Server</strong> will create a new copy <strong>of</strong> the entire file with the modifiedcontent and discard the old file. A new copy <strong>of</strong> the file needs to be created even for a smallchange in the <strong>FILESTREAM</strong> data file.If your application requires modification <strong>of</strong> data, you might want to review the expectedvolume <strong>of</strong> changes when you are deciding whether <strong>FILESTREAM</strong> storage is ideal. Iffrequent modifications are required, you might benefit more from keeping the data in a451

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

Saved successfully!

Ooh no, something went wrong!