简体   繁体   English

数据库文件收缩sql server的作用和副作用是什么

[英]what are the effects and side-effects of database file shrink sql server

I'm having a database on Sql server 2012 which size is 5 Gb. 我在Sql server 2012上有一个数据库,大小为5 Gb. and getting larger daily. 并且每天都在变大。

I need to shrink that database . 我需要缩小该database My question is:- 我的问题是:

Is it a good sign of shrinking the database weekly or monthly one. 这是每周或每月缩减数据库的一个好兆头。 as running out of space. 由于空间不足。 Are there any side effects like decreasing the performance. 是否有任何副作用,例如降低性能。

Generally, shrinking is bad because it takes up a lot of resources and cost performance, then you'd likely need to take a look at statistics and fragmentation of indexes at the same time. 通常,收缩是不好的,因为它会占用大量资源和成本效益,因此您可能需要同时查看统计信息和索引碎片。

Also because a database rarely really can be made "smaller" (more data doesn't take up less space), and because if it has grown to a specific size, it's because the data takes up that amount of space. 同样,因为很少能真正使数据库变得“更小”(更多数据不会占用更少的空间),并且因为如果数据库增长到特定大小,那是因为数据会占用该数量的空间。

So basically what you need to look at is why the database grows. 因此,基本上,您需要查看的是数据库增长的原因。 Is it unintended growth? 是意料之外的增长吗? Is it data files which grow or log files? 是增长的数据文件还是日志文件? If data files - do you store more data then you need? 如果是数据文件-您是否需要存储更多数据? If log files - how is your backup procedure and how do you handle the log file in that? 如果是日志文件-您的备份过程如何,以及如何处理其中的日志文件? Shrinking files usually is treating a symptom that something is wrong, more than treating what is actually wrong. 缩小文件通常是在处理某些问题的症状,而不是处理实际的错误。

So it is definitely not a good sign if it grows 'unexpected' or 'too much', and trying to find the cause would be the better route. 因此,如果它增长“意外”或“太多”,绝对不是一个好兆头,而试图找到原因是更好的选择。

(Of course, real life scenarios exists where you sometimes do have to make the 'bad' choice, but well - this was just generally speaking :)) (当然,现实生活中的场景有时需要您做出“错误的”选择,但是好吧,这只是一般而言:))

The only time a log file should be shrunk when there is some abnormal activities like increasing its size automatically. 发生某些异常活动(例如自动增加其大小)时,日志文件应仅收缩。 it is bad to shrink a log file regularly, see here to know why 定期收缩日志文件很不好,请参见此处了解原因

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

相关问题 在 edmx 文件(以支持 SQL Server 2005)上使用 ProviderManifestToken=2005 有什么副作用吗? - Any side-effects for using ProviderManifestToken=2005 on edmx -file (to support SQL Server 2005)? 有什么副作用SQL Server连接池 - what are side effects Connection Pooling with SQL Server 在SQL Server中启用DTC的副作用 - Side effects of enabling DTC in SQL Server 在SQL Server中更改数据库排序规则的风险和影响 - Risk and effects of changing database collation in SQL Server SQL Server:使用过滤索引是否有副作用? - SQL Server : are there any side effects to using a filtered index? 在SQL Server中收缩数据库 - Shrink the database in SQL Server 在事务中运行sql查询是否有副作用? - Are there side effects running a sql query within a transaction? SQL Server:在不使用游标的情况下为每一行调用具有副作用的存储过程 - SQL Server : call stored procedure with side effects for each row without using a cursor 了解使用(updlock,rowlock)对SQL Server中的查询的影响 - Understanding effects of with (updlock, rowlock) on a query in SQL Server SQL Server:在proc定义中使用'WITH RECOMPILE'的效果? - SQL Server: Effects of using 'WITH RECOMPILE' in proc definition?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM