question

niall5098 avatar image
niall5098 asked

rebuilding indexes with always on

HI All, I have an always on setup for 1 database . recently i ran an index rebuild job and i specifically set the sort to occur in the database log file. my assumption was that when the indexes were rebuild on prod they would occur on the secondary server in the db log file also. however what seems to have occurred is that the TEMPDB grew to a large size on the secondary server and i am wondering is that coincidence or does the rebuilt indexes get sorted in the secondary TEMPDB rather than the db log file? Thanks in advance,
tempdbalwayson
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Wilfred van Dijk avatar image
Wilfred van Dijk answered
I guess you've used the "SORT IN TEMPDB" option? Which means temporary sort/recreate operations are not using space in the datafile being processed, but in tempdb. So you should see this behaviour also on the primary replica. AlwaysOn is based on transaction replication (like mirroring). So every "REBUILD INDEX" statement is also executed on every replica
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

niall5098 avatar image niall5098 commented ·
HI Winfred, the quick answer is no. the sort is happening in main database on primary. however there was a disabled optimization job on the standby server which had the sort in TEMPDB enabled from a previous run. would that override the index rebuild from the primary side?
0 Likes 0 ·
Wilfred van Dijk avatar image Wilfred van Dijk commented ·
Don't think so. You can't write on secondary replicas. Are you sure this is happening on a database which is in an Availability group?
0 Likes 0 ·
niall5098 avatar image niall5098 commented ·
HI Wilfred, i know you can't write but an index rebuild on the primary which is performed within the db rather than the TEMPDB should be replicated to the standby. the peculiar thing is that the TEMPDB grows on the standby. i have altered the disabled job on the standby to see if the settings in that have any impact.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.