I have a SQL Server 2022 instance running in a Docker container on Linux. My understanding is that Docker containers can simply expand their disk usage to fill the entire volume space available. The space on the volume is about 10GB:
$ sudo df -h /var/lib/docker/
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 47G 34G 10G 78% /
Yet when I go into SSMS and look at the DB properties, it says "Database size 80.00 MB, Space Available 1.78MB". Why does it say only 1.78MB is available? Will my DB still be able to use all of that 10GB on the partition?
1 Answer 1
The database properties show the size of the files for the database. It is independent of the size of the disk or what the Docker container is currently consuming.
The Space Available
property on the database is how much space is left free within the database file, before a growth operation will be attempted to grow the file on disk.
SQL Server manages space internally to the data file of a database. Typically people pre-grow their data files to a reasonable size (sometimes the entirety of the disk available if it's the only database) to minimize growth operations, which can be a little costly of an operation. Then they'll monitor the actual space consumption of the database by looking at the internal file size and usage, such as by the Space Available
property.
-
OK, is there any way to get SQL Server to say how much disk space it thinks is available?Jez– Jez2023年04月05日 17:50:21 +00:00Commented Apr 5, 2023 at 17:50
-
@Jez It's probably possible in some obscure way or in one of the DMVs but I don't know off-hand. But you're probably better off pre-growing the data file of your database to an appropriate size (as recommended in my updated answer).J.D.– J.D.2023年04月05日 17:54:20 +00:00Commented Apr 5, 2023 at 17:54