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 1: Storing and Managing Unstructured DataWe now have an image, stored in the file system, but under the transactional control <strong>of</strong><strong>SQL</strong> <strong>Server</strong>, and which would be included in database backups, and so on. We are alsonow ready to take advantage <strong>of</strong> the performance benefits <strong>of</strong> streaming and fast file systemAPI access methods when reading and modifying this data, as we will see in Chapter 2.When to use <strong>FILESTREAM</strong>Despite the obvious advantages <strong>of</strong> <strong>FILESTREAM</strong> to <strong>SQL</strong> <strong>Server</strong> applications that useBLOB data, the decision <strong>of</strong> where and how to use it should be taken only after carefullyanalyzing the storage requirements, data usage patterns, possible administrativeoverheads, and so on.Size <strong>of</strong> the files<strong>The</strong> previously-referenced Micros<strong>of</strong>t Research paper, To BLOB or Not To BLOB: LargeObject Storage in a Database or a File System, suggests that, for BLOBs that are smaller than256 KB, the best performance will probably be obtained by simply storing the data directlyin the relational tables. Files larger than 1 MB are better stored in the file system, andmanaged through <strong>SQL</strong> <strong>Server</strong> using <strong>FILESTREAM</strong>. In that in-between region <strong>of</strong> 256 KBto 1 MB, the decision <strong>of</strong> which way to go can only be taken after analyzing the specificdata usage scenarios.Generally speaking, though, if the average size <strong>of</strong> the BLOB values that you expectyour application to process is below 1 MB, then direct storage in the database, using anormal VARBINARY(MAX) column, is likely to perform better in most cases. However,this may vary based on how write-intensive the workload is. Even 256 KB files that areread/updated many times per second in a VARBINARY(MAX) column will cause memoryexhaustion. <strong>The</strong> best way to take this decision is by running some tests that involve realworkload and usage patterns, and see what fits best in your specific environment.44

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

Saved successfully!

Ooh no, something went wrong!