Home All Groups Group Topic Archive Search About

Regarding Transaction Log



Author
22 Nov 2007 8:56 AM
Balaji
SQL Server book online says “Log records are written to disk when the
transactions are committed.” In case of re-indexing how does it work. I
understand the re-index is done as one single transaction which means the
details of the transaction log should be written to disk only after the
re-index is completed but I see the database transaction log grews during the
re-index process itself. Can some body explain

Author
22 Nov 2007 9:28 AM
Uri Dimant
Hi
Reindexing is fully logged operation. I will try you explain as I undertsand
how rebuild index does work very short.

1) SQL Server creates a new index (it will require additinal space) , as
such it needs to lock the index , create a metadata...

2) After creating the index SQL Server inserting the data into the new index
..

If the index operation creates or drops a clustered index and there are
nonclustered indexes on the table, (for 1 and 2) are repeated twice; once
for the new clustered index (or, for a drop operation, the heap), and again
for the nonclustered indexes which are all rebuilt.

3) SQL Server drops old statistics and old indexes






Show quoteHide quote
"Balaji" <Bal***@discussions.microsoft.com> wrote in message
news:71264C49-5CA5-486F-97CD-1FF2F12FA01D@microsoft.com...
> SQL Server book online says “Log records are written to disk when the
> transactions are committed.” In case of re-indexing how does it work. I
> understand the re-index is done as one single transaction which means the
> details of the transaction log should be written to disk only after the
> re-index is completed but I see the database transaction log grews during
> the
> re-index process itself. Can some body explain
Are all your drivers up to date? click for free checkup

Author
22 Nov 2007 9:43 AM
Balaji
Dear Uri,

I want to know when does the re-index operation flushes the log to disk from
"Log Cache" during the re-index process.

Show quoteHide quote
"Uri Dimant" wrote:

> Hi
> Reindexing is fully logged operation. I will try you explain as I undertsand
> how rebuild index does work very short.
>
> 1) SQL Server creates a new index (it will require additinal space) , as
> such it needs to lock the index , create a metadata...
>
> 2) After creating the index SQL Server inserting the data into the new index
> ..
>
> If the index operation creates or drops a clustered index and there are
> nonclustered indexes on the table, (for 1 and 2) are repeated twice; once
> for the new clustered index (or, for a drop operation, the heap), and again
> for the nonclustered indexes which are all rebuilt.
>
> 3) SQL Server drops old statistics and old indexes
>
>
>
>
>
>
> "Balaji" <Bal***@discussions.microsoft.com> wrote in message
> news:71264C49-5CA5-486F-97CD-1FF2F12FA01D@microsoft.com...
> > SQL Server book online says “Log records are written to disk when the
> > transactions are committed.” In case of re-indexing how does it work. I
> > understand the re-index is done as one single transaction which means the
> > details of the transaction log should be written to disk only after the
> > re-index is completed but I see the database transaction log grews during
> > the
> > re-index process itself. Can some body explain
>
>
>
Author
22 Nov 2007 9:54 AM
Uri Dimant
Hi
As I mentioned each operation is fully logged , it creates a new indexes so
its logged, it inserts a new data, again its logged.
Therefore , it is not good idea to run re-index on VLDB  as it may affect
perfomance an tables will be locked. Instead, the DBA should identify
heavily fragmented tables and rebuild indexes on them . There is also DBCC
INDEXDEFRAG commad , have you read about it?



Show quoteHide quote
"Balaji" <Bal***@discussions.microsoft.com> wrote in message
news:CCE110B9-77CD-4D53-8440-9628FF366835@microsoft.com...
> Dear Uri,
>
> I want to know when does the re-index operation flushes the log to disk
> from
> "Log Cache" during the re-index process.
>
> "Uri Dimant" wrote:
>
>> Hi
>> Reindexing is fully logged operation. I will try you explain as I
>> undertsand
>> how rebuild index does work very short.
>>
>> 1) SQL Server creates a new index (it will require additinal space) , as
>> such it needs to lock the index , create a metadata...
>>
>> 2) After creating the index SQL Server inserting the data into the new
>> index
>> ..
>>
>> If the index operation creates or drops a clustered index and there are
>> nonclustered indexes on the table, (for 1 and 2) are repeated twice; once
>> for the new clustered index (or, for a drop operation, the heap), and
>> again
>> for the nonclustered indexes which are all rebuilt.
>>
>> 3) SQL Server drops old statistics and old indexes
>>
>>
>>
>>
>>
>>
>> "Balaji" <Bal***@discussions.microsoft.com> wrote in message
>> news:71264C49-5CA5-486F-97CD-1FF2F12FA01D@microsoft.com...
>> > SQL Server book online says “Log records are written to disk when the
>> > transactions are committed.” In case of re-indexing how does it work. I
>> > understand the re-index is done as one single transaction which means
>> > the
>> > details of the transaction log should be written to disk only after the
>> > re-index is completed but I see the database transaction log grews
>> > during
>> > the
>> > re-index process itself. Can some body explain
>>
>>
>>
Author
22 Nov 2007 9:54 AM
Tibor Karaszi
BOL oversimplifies things. It should say something like:

Log records are force-written at commit. They can be written at an earlier time (for instance when a
checkpoint occurs and a dirty page is written which contains modifications which hasn't been
committed yet).

Show quoteHide quote
"Balaji" <Bal***@discussions.microsoft.com> wrote in message
news:71264C49-5CA5-486F-97CD-1FF2F12FA01D@microsoft.com...
> SQL Server book online says "Log records are written to disk when the
> transactions are committed." In case of re-indexing how does it work. I
> understand the re-index is done as one single transaction which means the
> details of the transaction log should be written to disk only after the
> re-index is completed but I see the database transaction log grews during the
> re-index process itself. Can some body explain

Bookmark and Share