Database snapshot files are sparse files. Only when a page is modified the sparse file is being written to. Reads of the snapshot must be able to know whether the sparse file contains a copied page or not. How does SQL Server know where to read from? Where is this information stored?
From the Microsoft SQL Server 2012 Internals book:
The snapshot files contain only the data that has changed from the source. For every file, SQL Server creates a bitmap that is kept in cache, with a bit for each page of the file, indicating whether that page has been copied to the snapshot. Every time a page in the source is updated, SQL Server checks the bitmap for the file to see if the page has already been copied and if hasn't it is copied at that time. This operation is called a copy-on-write operation.
The bitmap is stored in cache, not the file itself, so it is always readily available. When SQL Server shuts down or the database is closed, the bitmaps are lost and need to be reconstructed at database startup.
When performing reads, SQL Server checks the snapshot bitmap to determine where to read from.
Background from the documentation:
For a database snapshot, the database on which the snapshot was created. Database snapshots are dependent on the source database. The snapshots of a database must be on the same server instance as the database. Furthermore, if that database becomes unavailable for any reason, all of its database snapshots also become unavailable.
A file provided by the NTFS file system that requires much less disk space than would otherwise be needed. A sparse file is used to store pages copied to a database snapshot. When first created, a sparse file takes up little disk space. As data is written to a database snapshot, NTFS allocates disk space gradually to the corresponding sparse file.
Specify the default snapshot location on the Snapshot Folder page of the Configure Distribution Wizard. If you create a publication on a server that is not configured as a Distributor, specify a default snapshot location on the Snapshot Folder page of the New Publication Wizard.
To modify the default snapshot location
- On the Publishers page of the Distributor Properties - dialog box, click the properties button (…) for the Publisher for which you want to change the default snapshot location.
- In the Publisher Properties - dialog box, enter a value for the Default Snapshot Folder property.
This information about the publisher and distributor screens seems very wrong, as if you have to replicate a db in order to use db snapshots. It looks like this entry is conflating replication snapshot files with database snapshots.