New
Back
Database Management

Reliable database management for modern, high-performance systems.

Back
Data Modernisation

Reliable database management for modern, high-performance systems.

Back
Data Engineering

Reliable database management for modern, high-performance systems.

Back
Analytics & Intelligence

Reliable database management for modern, high-performance systems.

Back
Data Strategy Consulting

Reliable database management for modern, high-performance systems.

Finding the exact differential backup size in SQL Server

Thirunavukkarasu RM
Published on
April 1, 2021

A common question among DBAs is to find exact number of pages would be backed up during a differential backup.

We now have a solution to find the total number of pages which would be backed up during differential backup! This solution is availbale from SQL Server 2016 SP2. This can be done in using sys.dm_db_file_space_usage. Let's see how this is done using a new database

Create database sample

Now run the below query to find the total number of pages on sample database

use sample

go

select total_page_count from sys.dm_db_file_space_usage

go

Creating tables and inserting data into the sample table.

create table empdetail (EmpName char(8000));

go

INSERT INTO EmpDetail values('Thiru');

GO 1000

Now again run the below query to find the total number of pages in database.

use sample

go

select total_page_count from sys.dm_db_file_space_usage

go

Understanding sys.dm_db_file_space_usage

Let us run the below query to understand sys.dm_db_file_space_usage. Below output shows total number of pages in database and total number of pages modified after full backup. If you notice zero, then full backup was not performed or no change has occurred after the last full backup.

Perform full backup to understand the above example

BACKUP DATABASE [SAMPLE] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\sample.bak' WITH NOFORMAT, NOINIT, NAME = N'sample-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10

GO

As the next step, we are going to insert some sample records and show you the total number of pages modified after full backup.

INSERT INTO empdetail values('Arasu')

go 1000

Now run the sys.dm_db_file_space_usage to get total number of pages modified after full backup

Now you can easily find the total number pages which would be backed up during differential backup. In the above example, 1070 pages will be backup during the differential backup. The value of modified_extent_page_count will be reset during the full backup.

Thirunavukkarasu RM

Thirunavukkarasu Ramasamy has 17+ years of experience in database management and the Microsoft Data Platform, with expertise in SQL Server, database architecture, and data solutions. As the Senior Solution Architect of Geopits, he focuses on building scalable data platforms, modernizing database environments, and delivering reliable enterprise data solutions.

Our Latest Blogs

From monitoring to modernization, GeoPITS provides expert database management services that enhance performance, strengthen security, and reduce operational costs.

Ready to Transform Your Data?

Geopits works alongside your team as a strategic partner, starting with stabilizing your current databases, then modernizing your data infrastructure, and ultimately helping you unlock the full potential of AI.

170

Happy Clients so far

2100+

Databases Managed

142+

Successful Migrations

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.