sql - 删除行后留下FILESTREAM文件

标签 sql sql-server-2008 blob filestream

我已经在SQL 2008服务器上成功设置了FILESTREAM;但是我注意到,即使删除了包含FILESTREAM数据的行,物理数据文件似乎也没有被删除。

物理文件是指SQLServer托管目录中的文件,其文件名带有uniqueidentifer,而不是添加到dbase的原始文件。

有谁知道SQLServer是否最终将删除该文件?如果从dbase中删除了很多大文件,我希望能够快速回收空间。

最佳答案

FILESTREAM数据受事务控制,因此不会立即删除。

相反,SQL Server运行一个垃圾回收器,当确定已最终删除旧数据时,它将清除旧数据。

documentation:

FILESTREAM garbage collection is a background task that is triggered by the database checkpoint process. A checkpoint is automatically run when enough transaction log has been generated. For more information, see the SQL Server 2008 Books Online topic “CHECKPOINT and the Active Portion of the Log” (http://msdn.microsoft.com/en-us/library/ms189573.aspx). Given that FILESTREAM file operations are minimally logged in the database’s transaction log, it may take a while before the number of transaction log records generated triggers a checkpoint process and garbage collection occurs. If this becomes a problem, you can force garbage collection by using the CHECKPOINTstatement.

关于sql - 删除行后留下FILESTREAM文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1625001/

相关文章:

mysql - SELECT 与另一个表连接的特定行

node.js - Blob 保存为 [object Object] Nodejs

c# - 如何在存储过程中将 DateTime 格式传递给 MS sql server?

php - SQL查询通过用户id返回用户名

c# - 具有父子关系的自引用表使用 LINQ 表示文件树

sql-server-2008 - 在不同时间使用不同参数执行相同的 SSIS 包

mysql - 直接在主表中有一个BLOB字段是否正确?

java - 如何将 Java 中的 150 位整数(或 30 个 5 位整数)转换为 mysql 中的高效存储格式?

java - 当列的值为空时,getColumnCount 不计算该列吗?

sql - PERSISTED 列可以引用现有的持久字段吗?