2017-04-19 110 views

回答

0

數據庫的初始文件大小可以在數據庫創建指定。

CREATE DATABASE [MyDB] 
ON PRIMARY (Name = N'MyDB', FILENAME = N'C:\MyDB.mdf', SIZE = 5120KB, FILEGROWTH = 1024KB) 
LOG ON (NAME = N'MyDB_log', FILENAME = N'C:\MyDB_log.ldf', SIZE = 1024KB, FILEGROWTH = 10%) 

然後,當文件數據達到其容量時,您有兩個選項。
文件處於自動增長狀態,文件將自動增長FILEGROWTH大小(百分比或固定字節)。
否則,數據庫將僅ROLLBACK事務併發出錯誤。

然後之後,您可以通過以下要求檢查文件的大小。
該請求自SQL Server 2005起作用。
如果您需要SQL 2005下的請求,我需要一個請求。

這一個數據文件:

SELECT 
    D.name, 
    (SUM(F.size)*8)/1024 AS FileSize 
FROM sys.master_files F 
INNER JOIN sys.databases D 
ON D.database_id = F.database_id 
WHERE F.type_desc = 'ROWS' 
GROUP BY D.database_id, D.name 
ORDER BY D.database_id 

這一個日誌文件:

SELECT 
    D.name, 
    (SUM(F.size)*8)/1024 AS FileSize 
FROM sys.master_files F 
INNER JOIN sys.databases D 
ON D.database_id = F.database_id 
WHERE F.type_desc = 'LOG' 
GROUP BY D.database_id, D.name 
ORDER BY D.database_id 

參考文獻:
CREATE DATABASE
DATA FILE Full
LOG FILE Full

PS: Here a little note on how to choose weither autogrow or not.

0

SQL服務器根據傳遞請求分配內存分頁。

The I/O from an instance of the SQL Server Database Engine includes logical and physical reads. A logical read occurs every time the Database Engine requests a page from the buffer cache. If the page is not currently in the buffer cache, a physical read first copies the page from disk into the cache.

The instance then continues to acquire memory as needed to support the workload. As more users connect and run queries, SQL Server acquires the additional physical memory on demand.

例如,你犯了一個特定的選擇啓動後一次,頁面讀取被加載到內存中。
如果您在第一個之後執行相同的SELECT操作,頁面將直接從內存中讀取。

然後頁面保存在儘可能長的時間記憶,而當新頁需要被加載到內存中,如果沒有可用內存了一些乾淨的頁面可以從內存中釋放出來。

A SQL Server instance continues to acquire physical memory until it either reaches its max server memory allocation target or Windows indicates there is no longer an excess of free memory; it frees memory when it has more than the min server memory setting, and Windows indicates that there is a shortage of free memory.

乾淨的頁面是與數據文件數據保持同步的頁面。
反對一個髒頁面,這是一個頁面加載到內存中,修改,但尚未提交。

作簡短的:可能達到所有數據庫的總大小在你的情況下,如果你需要同時解決所有數據所需的內存大小。 如果記憶中的pagelife很短,您的表演將會減少。
您可以使用Perfmon或使用內置的DataCollector監控PageLife。

您還可以管理實例設置以分配最小/最大內存大小。根據系統和其他流程所需的其他資源。

參考文獻:
Writing Pages
Reading Pages
Dynamic Memory Management

+0

所以你說的是在創建過程中沒有分配給數據庫的大小。對? @ Hybris95 – svsLm

+0

你是在談論內存使用情況還是文件大小?這還不清楚 – Hybris95

+0

我正在談論尺寸@Hybris95 – svsLm

相關問題