4

I'm reading about SQL Server high availability solutions and disaster recovery and among the available resources the SQL Server have snapshot feature. In theory all seems like beautiful.

I also read that a snapshot will copy a database at a point in time and you can use this to restore a database.

In this answer there is a comment (by Peter Schofield, 2013) about SQL Server snapshots not having support, and is useful in a development environment for quick rollbacks.

[...] Perhaps the biggest hindrance to adoption is that Management Studio didn't offer support[...]

[...] It sounds like an ideal use of snapshots in a dev environment just for quick script deployments and quick roll backs.[...]

I would like to know if snapshots are really useful in production environments. What are some examples of usage in production, and please include personal examples about when you've used snapshots to provide a solution on production systems.

The principal objective is provide some examples of real usage and through these examples get some useful ideas for me and for everyone who will be reading this post.

In my case I use SQL Server 2017 Enterprise Edition in production environment.

5

[...] Perhaps the biggest hindrance to adoption is that Management Studio didn't offer support[...]

By this he meant that you do not have feature in SSMS to create snapshot of database, you have to rely on TSQL command to create database snapshot. This is also mentioned in Create Database Snapshot official document

The only way to create a SQL Server database snapshot is to use Transact-SQL. SQL Server Management Studio does not support the creation of database snapshots.

I agree the use of word "support" is not entirely clear. It should be that SSMS does not allow database snapshot creation.

The database snapshot "may" be used in production, it all depends on what you want from it and how it suits your requirement. Before going further please read Limitation of Database Snapshot.. Paul Randal has few more points about what can go wrong with database snapshots

6

As an opinion based question and answer, I suspect that this will get closed, but here's my two cents.

I have used and seen Database Snapshots in my production environments, although rarely.

Scenario A) We used database snapshots to provide a static image of a database for reporting (ETL to a datawarehouse) purposes. Daily a script would run at the specified time and create a snapshot for reports to use. This database was transactionally consistent as of it's date of creation so useful for that.

Scenario B) A terrible maintenance job that ran and did some analysis of a very deep table and then would start deleting appropriate entries. We created a snapshot at the start of this process to prevent any blocking from taking place. So the maintenance job was changed to get the list of "what needed work" from the snapshot, then drop the snapshot and then "do the work" on the live database.

The use case for database snapshots is niche for anything except CHECKDB. SQL Server does some lock isolation tricks in the background that make it a good choice if you need a quick and dirty fix for certain classes of operations.

  • 2
    There is a gray area with questions like this as to whether they are "opinon-based" or can provide real-world answers that are very useful. I think this question leans more to the latter--with examples such as the ones you provide here, although not exhaustive, can help people understand the appropriate use of the technology, – Tony Hinkle Nov 13 at 15:20
0

A production snapshot of a quiescent database is useful for for preparing a full sized Systems Assurance or "Production Support" database. Arguably these are not production, but should exist in a production-like enclave. In-flight transactions or referential integrity problems are avoided. problems caused by the unload of Table A an hour after Table B, say.

In the extreme, they can provide a fallback position for implementations or upgrades. Databases used for research, metrics, analytics, providing a "cube" of snapshots do not have to follow the same conventions as "business web" examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.