Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2017 May SQL Server: Committed Inner transactions never releases the log disk space

SQL Server: Committed Inner transactions never releases the log disk space

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

In this post, I am sharing a demonstration in which you can get to know that committed inner transactions are not releasing any log disk space in SQL Server.

One of our developers was telling me like when we commit the transaction it will release the occupied log space, but it is not entirely correct.
If you are dealing with nested transactions, it is true only for outer committed transactions.

Please check the below demonstration of this.

Create a sample database:

1
2
3
4
CREATE DATABASE Test_Tran;
GO
USE Test_Tran
GO

Check the log size:

1
2
3
4
5
6
CHECKPOINT
GO
DBCC SQLPERF ('LOGSPACE')
GO
-- the result
-- 4.557673

Create a sample table:

1
2
CREATE TABLE tbl_TestTrans(ID INT)
GO

Open outer and inner transaction and insert few sample records:

1
2
3
4
5
6
7
8
BEGIN TRANSACTION OuterTrans
GO
BEGIN TRANSACTION InnerTrans
GO
INSERT INTO tbl_TestTrans VALUES(88)
GO 1000
COMMIT TRANSACTION InnerTrans
GO

Check the log size:
The inner transaction is committed, but log size is increased, and it didn’t release the logs.

1
2
3
4
5
6
7
CHECKPOINT;
GO
DBCC SQLPERF ('LOGSPACE');
GO
 
-- the result:
-- 8.767107

Now, commit outer transaction:

1
2
COMMIT TRANSACTION OuterTrans
GO

Check the log size:
Once you commit your outer transaction, it releases the log size.

1
2
3
4
5
6
7
CHECKPOINT;
GO
DBCC SQLPERF ('LOGSPACE');
GO
 
-- the result:
-- 5.08

May 27, 2017Anvesh Patel
SQL Server Interview: If Outer transaction ROLLBACK, what happens to Inner transactionPostgreSQL: How to Insert text with single quote and apostrophe?

Leave a Reply Cancel reply

CAPTCHA
Refresh

*

Anvesh Patel
Anvesh Patel

Database Engineer

May 27, 2017 SQL ServerAnvesh Patel, COMMIT, database, database research and development, dbrnd, Inner transaction, Log, Outer transaction, SQL Query, SQL Server, SQL Server Administrator, SQL Server Error, SQL Server Monitoring, SQL Server Performance Tuning, SQL Server Programming, SQL Server Tips and Tricks, transaction, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....