Download presentation
Presentation is loading. Please wait.
Published byArnold Stafford Modified over 9 years ago
1
www.ExtremeExperts.com Connect with life www.connectwithlife.co.in Vinod Kumar Technology Evangelist - Microsoft www.ExtremeExperts.com http://blogs.sqlxml.org/vinodkumar
2
www.ExtremeExperts.com Agenda How database snapshots work Database snapshot creation steps Performance considerations with write- intensive workloads Restoring from a database snapshot
3
www.ExtremeExperts.com Row-1 Tran2 (Select) Tran1 (Update) X-Lock S-LockBlocked Row-1 Reader Writer Blocking
4
www.ExtremeExperts.com Database Snapshot – How it really works 1 Pages 2345678910111213141516 CreditSS1 – Read-Only Database Snapshot CREATE DATABASE CreditSS1 (…) AS SNAPSHOT OF Credit Credit – Database USE Credit UPDATE… ( pages 4, 9, 10 ) USE CreditSS1 SELECT… ( pages 4, 6, 9, 10, 14 ) 4910 12345678910111213141516
5
www.ExtremeExperts.com About Database Snapshots (1) Database snapshots are read only You can not change any data You can not create any new object Transactional consistent Consistent as of a particular point-in-time Includes all metadata, tables, indexes, stored procs, etc. If you create an index on a table in the source database after creating the database snapshot, the index will not be there in the database snapshot Database snapshots have no transaction log One data file for each corresponding data file in the source database You can create more than one database snapshot on the same source database You can create a database snapshot on a mirror database (not part of the discussion today)
6
www.ExtremeExperts.com About Database Snapshots (2) Enterprise Edition and Developer Edition only Must reside on The same instance as the source db NTFS filesystem Cannot Backup / Restore Detach / Attach Drop (or RESTORE WITH REPLACE) the source database if any database snapshot(s) exists on it. Need to drop the database snapshot(s) first. Reside on Fat32 filesystem / Raw Partitions Be a source for another database snapshot Be source for Scalable Shared Database (SSD) Create db snapshots on model, master, and tempdb databases (but can create on msdb)
7
www.ExtremeExperts.com Sparse Files Database snapshots use sparse files as data files Sparse files require NTFS Logical size of the sparse file is equal to the size of the corresponding data file of the source database, at the time of creating the database snapshot But the sparse file doesn’t reserve all the space Physical size is only the amount of space consumed by the original pages copied from the source database To find the physical size of a sparse file properties → size on disk select * from fn_virtualfilestats(db_id(), null); and look for the column BytesOnDisk You may over-allocate your disk space due to the fact that sparse files not actually reserve all the space they might need
8
www.ExtremeExperts.com Copy On Write Database snapshots use the “COW” technology to maintain point-in-time data Copy on FIRST write ONLY Only the first change to a page will cause the page to be copied; the next billion changes are ‘free’
9
www.ExtremeExperts.com Database Snapshots Usage Scenarios Point-in-time reporting Offloading reporting to mirror server Restoring in a test environment in order to restart a test from the same initial database state Safeguard against human / machine errors Administrative errors: before executing a large batch job, schema change, etc. User errors
10
www.ExtremeExperts.com Database Snapshot creation steps
11
www.ExtremeExperts.com Database Snapshot Creation Steps CREATE DATABASE … AS SNAPSHOT command issued Checkpointing occurs Database snapshot files opened Database snapshot startup Recovery starts Analysis phase Redo phase Undo phase Recovery finished
12
www.ExtremeExperts.com How many Database Snapshots can my system handle? On a given source database There is no built-in limit Factors to consider: IO load (especially writes) Database size Database activity (especially writes) RAM
13
www.ExtremeExperts.com When is the database snapshot data current?
14
www.ExtremeExperts.com When is the database snapshot data current? Time CREATE DATABASE … AS SNAPSHOT command issued Database Snapshot creation completed Data in the DB snapshot is current as of this time Data that is committed in the source database as of the beginning of the analysis phase of the database snapshot recovery will be present in the database snapshot
15
www.ExtremeExperts.com Restoring from a Database Snapshot aka “Reverting to a Database Snapshot” RESTORE DATABASE AdventureWorks FROM DATABASE_SNAPSHOT = 'AdvWorks_DBSS1' Before restoring from a database snapshot, all other database snapshots must be dropped Even though you can restore from a database snapshot, it is not an alternative to regular database backups Not useful in media failure The transaction log is rebuilt during restore Can not roll forward using previous transaction log backups after restoring from a database snapshot
16
www.ExtremeExperts.com Querying a Database Snapshot Querying a database snapshot requires reading pages from the Source database Database snapshot sparse file The database snapshot is a separate database for all practical purposes The same physical pages on disk are loaded and stored separately in the buffer pool for the source database and the database snapshot
17
www.ExtremeExperts.com Querying a DB Snapshot
18
www.ExtremeExperts.com Feedback / QnA Your Feedback is Important! Please take a few moments to fill out our online feedback form at: > For detailed feedback, use the form at http://www.connectwithlife.co.in/vtd/helpdesk.aspx Or email us at vtd@microsoft.com Use the Question Manager on LiveMeeting to ask your questions now!
19
www.ExtremeExperts.com © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.