简体   繁体   English

什么正在使用我在SQL Server中的所有存储

[英]What is using all my storage in SQL server

I have a SQL server database that according Properties => files, is using 47GB of disk space in the primary file group. 我有一个SQL Server数据库,根据Properties => files,在主文件组中使用47GB的磁盘空间。

I am 99% sure my database is not this big. 我99%确信我的数据库不是那么大。

I ran the query from this post https://www.mssqltips.com/sqlservertip/1177/determining-space-used-for-all-tables-in-a-sql-server-database/ 我从这篇文章中运行查询https://www.mssqltips.com/sqlservertip/1177/determining-space-used-for-all-tables-in-a-sql-server-database/

and according to this my reserved space is only 1 GB, so how can my DB possibly be using this much space? 并据此我的保留空间只有1 GB,那么我的数据库怎么可能使用那么多的空间?

I have shrunk the log file but as I said above, it is the primary file that is this size 我缩小了日志文件,但是如上所述,它是该大小的主文件

在此处输入图片说明

As per my comment: When a database file grows, it won't release space; 根据我的评论: 数据库文件增长时,它不会释放空间; most likely it got to 47GB at some point perhaps when you were doing a large load and you since deleted the data? 最有可能在某个时候达到了47GB,也许是在您进行大负载并且您删除了数据之后? Not releasing the space is intentional, and in fact shrinking your database is a dangerous path to go down unless you know what you're doing; 不释放空间是有意的,实际上,除非知道自己在做什么,否则缩小数据库是一个危险的失败之路。 as it'll easily cause things like fragmentation of your indexes. 因为它很容易导致索引碎片等问题。

You can find out how much space, and unused space, there is by using objects like sys.sp_spaceused; 您可以使用sys.sp_spaceused;对象sys.sp_spaceused;有多少空间和未使用的空间sys.sp_spaceused; Which will detail the amount of free space in the unallocated space column. 这将详细说明unallocated space列中的可用空间量。

As noted above, it's not advised you shrink the database unless you really must. 如上所述,除非确实需要,否则不建议您收缩数据库。 Fragmentation will very likely occur during a shrink; 在收缩过程中很可能会发生碎片; which could have (significant) impacts on the performance of your database. 这可能会对数据库性能产生(重大)影响。

A database is made up of reserved space and of that a portion will be available space. 数据库由保留空间组成,其中一部分将是可用空间。 As the db grows the available space gets smaller until an autogrowth is triggered. 随着数据库的增长,可用空间会变小,直到触发自动增长。 The autogrowth increments are set as a value or percentage. 自动增长的增量设置为值或百分比。 It is possible that when the database was initially created an initial value of 47023 was set. 最初创建数据库时,可能会设置初始值为47023。 You can free up that available space back to the OS but you need to shrink the data file, not the log file, but just be cognizant of how your database is growing and how often those auto-growths are happening because there could be a performance compromise to doing that. 您可以将可用空间释放回操作系统,但是您需要收缩数据文件(而非日志文件),而只是要了解数据库的增长方式以及这些自动增长的频率,因为这可能会导致性能下降。这样做的妥协。

You may find it very useful to run two built in SSRS reports. 您可能会发现运行两个内置的SSRS报告非常有用。 To do so (in SQL Server Management Studio) right click on the database name and then ten selections down is a tab marked reports. 为此(在SQL Server Management Studio中),右键单击数据库名称,然后向下选择十个选项卡,将其标记为“报告”。 Click on it and try the 'Disk Usager' report and the 'Disk Usage by Top Tables' report. 单击它,然后尝试“ Disk Usager”报告和“ Top Tables磁盘使用情况”报告。 They are very clear reports and you may be surprised at how large certain tables are. 它们是非常清晰的报告,您可能会对某些表有多大感到惊讶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM