Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BLOCKING CAUSED BY REORGANIZE OF INDEX JOB IN SQL SERVER 2005


BLOCKING CAUSED BY REORGANIZE OF INDEX JOB IN SQL SERVER 2005

Author
Message
Ivan Mohapatra
Ivan Mohapatra
SSC-Enthusiastic
SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)

Group: General Forum Members
Points: 125 Visits: 495
hi all,
need your help on this.

i have a job which is reorganizing the index and with that i am having a issue of blocking when ever the job is running the blocking is coming up.AS per my knowledge reorganize of index is online and it should not create long holding blocking or blocking due to any update or select.

guide me if i am wrong and suggest for a solution and why the blocking happening ?



thanks
Ivan :-)
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2930 Visits: 4076
Two points ...

1) are you running this maintenance job in peak hours... it should be run in nights (OFF - peak hours)
2) have you selectiong the advanced option in reindxing/rebuilding" like 'Sort in Tempdb ' and "Keep index online while .."

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7542 Visits: 15175
Rebuilding indexes will take locks; reorganising won't. Please will you post your code?

John
Ivan Mohapatra
Ivan Mohapatra
SSC-Enthusiastic
SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)

Group: General Forum Members
Points: 125 Visits: 495
Reorganize of index is always online by-Default and we run it off hours less transaction.
Ivan Mohapatra
Ivan Mohapatra
SSC-Enthusiastic
SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)

Group: General Forum Members
Points: 125 Visits: 495
below is the script that i use to reorganize the index

DECLARE @Database VARCHAR(255)


DECLARE @Table VARCHAR(255)

DECLARE @cmd NVARCHAR(500)

DECLARE @fillfactor INT

DECLARE @Statement NVARCHAR(300)



SET @fillfactor = 90



DECLARE DatabaseCursor CURSOR FOR

SELECT name

FROM sys.databases

WHERE name NOT IN (''master'',''msdb'',''tempdb'',''model'')

AND DATABASEPROPERTYEX(name, ''Status'')=''ONLINE'' AND is_read_only<>1

ORDER BY 1







OPEN DatabaseCursor



FETCH NEXT FROM DatabaseCursor INTO @Database

WHILE @@FETCH_STATUS = 0

BEGIN



SET @cmd = ''DECLARE TableCursor CURSOR FOR SELECT ''''['''' + table_catalog + ''''].['''' + table_schema + ''''].['''' +

table_name + '''']'''' as tableName FROM '' + @Database + ''.INFORMATION_SCHEMA.TABLES

WHERE table_type = ''''BASE TABLE''''''



-- create table cursor

EXEC (@cmd)



OPEN TableCursor



FETCH NEXT FROM TableCursor INTO @Table

WHILE @@FETCH_STATUS = 0

BEGIN



IF (@@MICROSOFTVERSION / POWER(2, 24) >= 9)

BEGIN

-- SQL 2005 or higher command

SET @cmd = ''ALTER INDEX ALL ON '' + @Table + '' REORGANIZE ''

EXEC (@cmd)

--PRINT (@cmd)

END

ELSE

BEGIN

-- SQL 2000 command

DBCC DBREINDEX(@Table,'' '',@fillfactor)



END



--PRINT N''UPDATING STATISTICS '' + @Table

SET @Statement = ''UPDATE STATISTICS '' + @Table + '' WITH FULLSCAN''

EXEC sp_executesql @Statement

--PRINT @Statement



FETCH NEXT FROM TableCursor INTO @Table

END



CLOSE TableCursor

DEALLOCATE TableCursor



FETCH NEXT FROM DatabaseCursor INTO @Database

END

CLOSE DatabaseCursor

DEALLOCATE DatabaseCursor
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7542 Visits: 15175
I don't know why that would hold a lock for a long period of time. Have you tried to use sys.dm_os_waiting_tasks to see which session is doing the blocking?

John
Ivan Mohapatra
Ivan Mohapatra
SSC-Enthusiastic
SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)

Group: General Forum Members
Points: 125 Visits: 495
yes that is what i am asking i am getting blocking email when ever this job is running so asked you all to help me to find a solution .
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2930 Visits: 4076
Do we need to update statistics AFTER index rebuild/reorgainze ??

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Ivan Mohapatra
Ivan Mohapatra
SSC-Enthusiastic
SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)

Group: General Forum Members
Points: 125 Visits: 495
Well that is not the issue over here plz read my question throughly and then reply.
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7542 Visits: 15175
What is a blocking email and under what circumstances do you get one? Have you managed to ascertain which particular statement is causing the blocking?

John
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search