|
| 1 | +<img src="https://erikdarling.com/wp-content/uploads/2025/08/darling-data-logo_RGB.jpg" width="300px" /> |
| 2 | + |
| 3 | +# TestBackupPerformance |
| 4 | + |
| 5 | +Finding the fastest backup settings for your database shouldn't require guesswork. This procedure tests every combination of file count (striping), compression, buffer count, and max transfer size, then ranks the results so you can see what actually works best on your hardware. |
| 6 | + |
| 7 | +Results are persisted to `dbo.backup_performance_results` so you can compare across runs, servers, and databases. |
| 8 | + |
| 9 | +## Parameters |
| 10 | + |
| 11 | +| parameter_name | data_type | description | valid_inputs | defaults | |
| 12 | +|-----------------------------|-----------|------------------------------------------------------------------------|------------------------------------------------------------|-----------------------| |
| 13 | +| @database_name | sysname | database to back up | a valid database name | NULL (required) | |
| 14 | +| @backup_path | nvarchar | directory path, DEFAULT for instance default, or NUL to discard | a valid directory path, DEFAULT, or NUL | NULL (required) | |
| 15 | +| @file_count_list | varchar | comma-separated list of file counts (backup stripes) | comma-separated integers | 1,2,4 | |
| 16 | +| @compression_list | varchar | comma-separated list: 0 = no compression, 1 = compressed | comma-separated 0s and 1s | 0,1 | |
| 17 | +| @buffer_count_list | varchar | comma-separated list of buffer counts (0 = SQL Server default) | comma-separated integers (0 for default) | 0,15,30,50 | |
| 18 | +| @max_transfer_size_list | varchar | comma-separated list of max transfer sizes in bytes (0 = default 1MB) | comma-separated integers, multiples of 65536, max 4194304 | 0,2097152,4194304 | |
| 19 | +| @stats | tinyint | backup completion percent to print progress at | 1-100 | 1 | |
| 20 | +| @iterations | integer | times to repeat each configuration for averaging | a positive integer | 1 | |
| 21 | +| @help | bit | how you got here | 0 or 1 | 0 | |
| 22 | +| @debug | bit | prints dynamic sql, displays parameter and variable values | 0 or 1 | 0 | |
| 23 | +| @version | varchar | OUTPUT; for support | none | none; OUTPUT | |
| 24 | +| @version_date | datetime | OUTPUT; for support | none | none; OUTPUT | |
| 25 | + |
| 26 | +## Examples |
| 27 | + |
| 28 | +```sql |
| 29 | +-- Test with defaults (24 combinations: 3 file counts x 2 compression x 4 buffer counts x 3 transfer sizes) |
| 30 | +EXECUTE dbo.TestBackupPerformance |
| 31 | + @database_name = N'YourDatabase', |
| 32 | + @backup_path = N'D:\Backups'; |
| 33 | + |
| 34 | +-- Test throughput without disk I/O (backup to NUL device) |
| 35 | +EXECUTE dbo.TestBackupPerformance |
| 36 | + @database_name = N'YourDatabase', |
| 37 | + @backup_path = N'NUL'; |
| 38 | + |
| 39 | +-- Use the instance's default backup directory |
| 40 | +EXECUTE dbo.TestBackupPerformance |
| 41 | + @database_name = N'YourDatabase', |
| 42 | + @backup_path = N'DEFAULT'; |
| 43 | + |
| 44 | +-- Run 3 iterations per combination for more stable averages |
| 45 | +EXECUTE dbo.TestBackupPerformance |
| 46 | + @database_name = N'YourDatabase', |
| 47 | + @backup_path = N'D:\Backups', |
| 48 | + @iterations = 3; |
| 49 | + |
| 50 | +-- Narrow the test to specific settings |
| 51 | +EXECUTE dbo.TestBackupPerformance |
| 52 | + @database_name = N'YourDatabase', |
| 53 | + @backup_path = N'D:\Backups', |
| 54 | + @file_count_list = '1,4,8', |
| 55 | + @compression_list = '1', |
| 56 | + @buffer_count_list = '0,50', |
| 57 | + @max_transfer_size_list = '0,4194304', |
| 58 | + @iterations = 3; |
| 59 | +``` |
| 60 | + |
| 61 | +## Result Sets |
| 62 | + |
| 63 | +1. **All configurations ranked by throughput** -- every combination ranked best to worst |
| 64 | +2. **Best config per compression setting** -- fastest compressed vs fastest uncompressed |
| 65 | +3. **Parameter impact** -- which knob matters most (larger spread = bigger effect) |
| 66 | +4. **Efficiency** -- best throughput per MB of buffer RAM (filtered to configs within 80% of peak) |
| 67 | +5. **Consistency** -- min/max/stddev per config (only when `@iterations > 1`) |
| 68 | + |
| 69 | +## Notes |
| 70 | + |
| 71 | +* **BUFFERCOUNT** and **MAXTRANSFERSIZE** memory is allocated outside the buffer pool. The procedure warns when a combination will use more than 1 GB. |
| 72 | +* Backup files are automatically cleaned up after each test. NUL backups skip cleanup. |
| 73 | +* The `dbo.backup_performance_results` table is created automatically on first run. |
0 commit comments