I have a number of databases that are being transactionally replicated from SQL 2000 Enterprise edition publisher to SQL 2005 Enterprise edition subscriber. I have included indexes in the replication. The subscriber database is then accessed and the data de-normalised and aggregated for reporting purposes.
My question is this: I want to periodically re-build the indexes on the publisher and subscriber via an automated task. If I rebuild the indexes on the publisher, will that automatically replicate to the subscriber? Will there be a problem with the "snapshot being out of date", and therefore replication stopping? I run a new snapshot once a day in the small hours of the morning. If there is likely to be a problem with the rebuild throwing the replication out, would it be wise to have the rebuild job running just before the new snapshot is taken?
Any help/advice appreciated.
No, the index rebuild isn't replicated. You would have to rebuild the indexes on the publisher and subscriber separately.|||Or there is another option is to use @.pre/post_snapshot_script. You can use subscriber index rebuilding actions into a script and set the script as @.pre/post_snapshot_script in publication properties page -->Snapshot or through sql (sp_changepublication/sp_changemergepublication).
For example, as for post snapshot script, Distribution agent/merge agent will run the pre-snapshot script before any of the replicated object scripts when applying the snapshot at a Subscriber. The script is executed in the security context used by the Merge Agent when connecting to the subscription database. Pre-snapshot scripts are not run on SQL Server Mobile Subscribers.
Refer to: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/28a629a1-7374-4614-9b04-279d290a942a.htm
Therefore, once you rebuild index in publisher side, reinitialize sub, sub side index will be rebult through pre/post snapshot script as well.
Hope the above information will help.
-Yunjing
No comments:
Post a Comment