2
A
回答
7
活動監視器將顯示正在執行的內容。
DBCC OPENTRAN
將顯示最早的未結交易。
還有動態管理視圖sys.dm_tran_active_transactions
。例如,這裏是一個說明你的進程日誌文件使用情況的查詢:
-- This query returns log file space used by all running transactions.
select
SessionTrans.session_id as [SPID],
enlist_count as [Active Requests],
ActiveTrans.transaction_id as [ID],
ActiveTrans.name as [Name],
ActiveTrans.transaction_begin_time as [Start Time],
case transaction_type
when 1 then 'Read/Write'
when 2 then 'Read-Only'
when 3 then 'System'
when 4 then 'Distributed'
else 'Unknown - ' + convert(varchar(20), transaction_type)
end as [Transaction Type],
case transaction_state
when 0 then 'Uninitialized'
when 1 then 'Not Yet Started'
when 2 then 'Active'
when 3 then 'Ended (Read-Only)'
when 4 then 'Committing'
when 5 then 'Prepared'
when 6 then 'Committed'
when 7 then 'Rolling Back'
when 8 then 'Rolled Back'
else 'Unknown - ' + convert(varchar(20), transaction_state)
end as 'State',
case dtc_state
when 0 then NULL
when 1 then 'Active'
when 2 then 'Prepared'
when 3 then 'Committed'
when 4 then 'Aborted'
when 5 then 'Recovered'
else 'Unknown - ' + convert(varchar(20), dtc_state)
end as 'Distributed State',
DB.Name as 'Database',
database_transaction_begin_time as [DB Begin Time],
case database_transaction_type
when 1 then 'Read/Write'
when 2 then 'Read-Only'
when 3 then 'System'
else 'Unknown - ' + convert(varchar(20), database_transaction_type)
end as 'DB Type',
case database_transaction_state
when 1 then 'Uninitialized'
when 3 then 'No Log Records'
when 4 then 'Log Records'
when 5 then 'Prepared'
when 10 then 'Committed'
when 11 then 'Rolled Back'
when 12 then 'Committing'
else 'Unknown - ' + convert(varchar(20), database_transaction_state)
end as 'DB State',
database_transaction_log_record_count as [Log Records],
database_transaction_log_bytes_used/1024 as [Log KB Used],
database_transaction_log_bytes_reserved/1024 as [Log KB Reserved],
database_transaction_log_bytes_used_system/1024 as [Log KB Used (System)],
database_transaction_log_bytes_reserved_system/1024 as [Log KB Reserved (System)],
database_transaction_replicate_record_count as [Replication Records],
command as [Command Type],
total_elapsed_time as [Elapsed Time],
cpu_time as [CPU Time],
wait_type as [Wait Type],
wait_time as [Wait Time],
wait_resource as [Wait Resource],
reads as [Reads],
logical_reads as [Logical Reads],
writes as [Writes],
open_transaction_count as [Open Transactions],
open_resultset_count as [Open Result Sets],
row_count as [Rows Returned],
nest_level as [Nest Level],
granted_query_memory as [Query Memory],
SUBSTRING(SQLText.text,ExecReqs.statement_start_offset/2,(CASE WHEN ExecReqs.statement_end_offset = -1 then LEN(CONVERT(nvarchar(max), SQLText.text)) * 2 ELSE ExecReqs.statement_end_offset end - ExecReqs.statement_start_offset)/2) AS query_text
from
sys.dm_tran_active_transactions ActiveTrans (nolock)
inner join sys.dm_tran_database_transactions DBTrans (nolock)
on DBTrans.transaction_id = ActiveTrans.transaction_id
inner join sys.databases DB (nolock)
on DB.database_id = DBTrans.database_id
left join sys.dm_tran_session_transactions SessionTrans (nolock)
on SessionTrans.transaction_id = ActiveTrans.transaction_id
left join sys.dm_exec_requests ExecReqs (nolock)
on ExecReqs.session_id = SessionTrans.session_id
and ExecReqs.transaction_id = SessionTrans.transaction_id
outer apply sys.dm_exec_sql_text(ExecReqs.sql_handle) AS SQLText
where SessionTrans.session_id is not null -- comment this out to see SQL Server internal processes
0
您可以使用sql server profiler來顯示每個執行的事務,它的開始時間和結束時間以及很多事情,我認爲您可以看到導致問題的原因。 我希望這對你有所幫助。
1
如果事務日誌增長如此之快是這麼短的時間,這意味着大量的報表,使數據或結構的變化已經執行。如果你的數據庫可以處理大型的BLOB記錄,那麼你可以先試着看那裏。
事件探查器不會幫你找出以前發生的事情,但它可以幫助你,如果這仍然在繼續。
如果您想要讀取交易記錄,您需要第三方transaction log reader。市場上最好的解決方案是ApexSQL Log,它在相似的情況下爲我節省了幾次時間。
但是,如果您的數據庫在sql server 2000上運行,則可以嘗試使用Red Gate的SQL Log Rescue,因爲它是免費的。 Thrid解決方案是嘗試找到Lumigent Log Explorer(產品已打折,但也許可以在網上找到它)。
Try'em all,看看哪個更適合你。
相關問題
- 1. 事務日誌SQL Server
- 2. SQL Server 2005的事務日誌太大
- 3. Sql Server事務日誌讀取器
- 4. SQL Server事務日誌截斷/收縮
- 5. SQL Server事務日誌VLF訪問
- 6. 不太瞭解SQL Server事務日誌
- 7. Sql Server事務日誌備份失敗
- 8. 閱讀SQL Server事務日誌
- 9. SQL Server事務日誌ldf文件
- 10. SQL Server 2012未使用事務日誌
- 11. SQL Server ETL進程事務日誌
- 12. SQL Server事務日誌已滿
- 13. 在線SQL Server備份事務日誌
- 14. sql server 2008恢復事務日誌?
- 15. SQL Server 2008備份事務日誌
- 16. 如何拆分SQL Server事務日誌
- 17. SQL Server事務日誌在日誌中的使用
- 18. SQL事務日誌
- 19. 查看SQL Server 2014中的所有事務日誌
- 20. WCF服務不寫入事件日誌
- 21. 從寫入事務日誌複製嗎?
- 22. 將SQL Server 2008 R2事務日誌還原到SQL Server 2005
- 23. 正在查找SQL事務日誌文件查看器
- 24. Sql Server 2008事務複製和事務日誌
- 25. 如何查看SQL Server 2005事務日誌文件
- 26. SQL Server - 查詢日誌?
- 27. 寫入ETW事件日誌
- 28. SQL事務日誌增長
- 29. SQL Server 2008日誌日誌
- 30. SQL Server 2008事務日誌:日期/時間