June 5, 2015 at 4:29 pm
What is the difference b/n size & space available when you right click on database properties?
June 5, 2015 at 4:34 pm
They're more or less what it says on the tin 🙂
Size is just the total size of the database files on disk.
Space available is the total free space within the database files.
Cheers!
June 5, 2015 at 4:49 pm
so if the datafile size is higher than database size i.e. there is more unused space right? What is the use of that unused space
June 5, 2015 at 5:05 pm
The main point of having available unused space is to prevent costly autogrowth events.
So, let's say you have a database file with just one data file and one log file.
The data file is 1 GB and has 100 MB free/available space, while the log file is 500 MB and has 50 MB free/available space.
In that case, what you're looking at (the properties of the database in SSMS), would show a size of 1.5 GB and 150 MB free space.
If you didn't have any available space in either file, when you either added data or wrote to the log, the respective file would have to grow to allow the operation to continue. That growth doesn't come for free (especially with log files, which can't benefit from instant file initialization).
That's why it's best to size files to accommodate expected growth over the near future (at least), if at all possible.
Cheers!
June 5, 2015 at 11:21 pm
You also need some headroom for certain maintenance such as REBUILDing indexes. Any index over 128 extents (that's just 8 megabytes) that needs to be rebuilt will first be rebuilt and, once the new version of the index has been committed, only then will the old index be dropped. If you do it in an online fashion, there's also a "transaction" working table that is built to keep track of things that happen while the rebuild is occurring.
Once those are gone, the extra "unused" space will remain and that's usually not a bad thing.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 7, 2015 at 3:21 pm
I am little confused here.
Database is size is only .mdf file size. I thought free space is available means it tells us the free space available in the data file.
Is it includes the log size?
June 7, 2015 at 3:50 pm
If we're talking about the values for Size and Space Available when you right-click a database and look at the General tab in Properties, then yes, the value for Size is the sum of the size of data and log files, not just data files.
Space Available may only be free space in data files, not logs. I never use the GUI for this (I usually use sys.database_files and FILEPROPERTY), so I'm not completely sure. Some preliminary tests indicate that it is indeed only free space in data files, while Size is total size of data and log. Weird, and yet another reason not to use the GUI 🙂
Probably it's using the same calculations as sp_spaceused, which seems to do the same, as documented here: https://msdn.microsoft.com/en-us/library/ms188776.aspx.
database_size will always be larger than the sum of reserved + unallocated space because it includes the size of log files, but reserved and unallocated_space consider only data pages.
(emphasis mine)
Cheers!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply