Transactional replication pre and post scripts The 2019 Stack Overflow Developer Survey...

Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?

Deal with toxic manager when you can't quit

Why can't devices on different VLANs, but on the same subnet, communicate?

Can a flute soloist sit?

What is this business jet?

Why not take a picture of a closer black hole?

If a sorcerer casts the Banishment spell on a PC while in Avernus, does the PC return to their home plane?

How do I free up internal storage if I don't have any apps downloaded?

Did any laptop computers have a built-in 5 1/4 inch floppy drive?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Output the Arecibo Message

Worn-tile Scrabble

How to type a long/em dash `—`

Why doesn't UInt have a toDouble()?

Does HR tell a hiring manager about salary negotiations?

How to translate "being like"?

How to charge AirPods to keep battery healthy?

Why isn't the black hole white?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Getting crown tickets for Statue of Liberty

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

How to type this arrow in math mode?

How to support a colleague who finds meetings extremely tiring?

Straighten subgroup lattice



Transactional replication pre and post scripts



The 2019 Stack Overflow Developer Survey Results Are InSQL Server 2008 - Partitioning and Clustered IndexesWhy doesn't this transactional replication post script work? (Works in SSMS and SQLCmd.exe)Replication MadnessSQL Server : replication between two different locationsShould the index on an identity column be nonclustered?Merge replication: some subscribers initializing by downloading changes multiple timesShould I remove this clustered index?Considerations for performance comparison with a high fragmented heap?MS SQL Server merge replication cannot find file specifiedHow to pause the subscriber end of transactional replication





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















Just a preface that I'm working at the moment as an accidental DBA so sorry for any ignorance.



I need to completely rebuild one of our transactional replications. The indexing strategy is different on the subscriber database than it is on the publisher, the primary key is the same but the clustered index on NC indexes are different. I am aware that the tables by default are completely dropped on the subscriber. I believe I can use scripts pre and post snapshot application to drop and create indexes.



Both the clustered indexes on the subscriber and publisher are UniqueIdentifier but different columns. The table has nearly 1 billion rows and is sadly pretty wide. Just thought that I'd provide that information in case it makes a difference.



My questions are:




  • Is using the post execution scripts the best way to go about this?

  • If the clustered index is different on the subscriber than the publisher am I best to allow the bulk insert to happen with the publisher clustered index or would it be better to set the alternate clustered index before the bulk insert?


Thanks in advance for any help.










share|improve this question














bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    1















    Just a preface that I'm working at the moment as an accidental DBA so sorry for any ignorance.



    I need to completely rebuild one of our transactional replications. The indexing strategy is different on the subscriber database than it is on the publisher, the primary key is the same but the clustered index on NC indexes are different. I am aware that the tables by default are completely dropped on the subscriber. I believe I can use scripts pre and post snapshot application to drop and create indexes.



    Both the clustered indexes on the subscriber and publisher are UniqueIdentifier but different columns. The table has nearly 1 billion rows and is sadly pretty wide. Just thought that I'd provide that information in case it makes a difference.



    My questions are:




    • Is using the post execution scripts the best way to go about this?

    • If the clustered index is different on the subscriber than the publisher am I best to allow the bulk insert to happen with the publisher clustered index or would it be better to set the alternate clustered index before the bulk insert?


    Thanks in advance for any help.










    share|improve this question














    bumped to the homepage by Community 5 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      Just a preface that I'm working at the moment as an accidental DBA so sorry for any ignorance.



      I need to completely rebuild one of our transactional replications. The indexing strategy is different on the subscriber database than it is on the publisher, the primary key is the same but the clustered index on NC indexes are different. I am aware that the tables by default are completely dropped on the subscriber. I believe I can use scripts pre and post snapshot application to drop and create indexes.



      Both the clustered indexes on the subscriber and publisher are UniqueIdentifier but different columns. The table has nearly 1 billion rows and is sadly pretty wide. Just thought that I'd provide that information in case it makes a difference.



      My questions are:




      • Is using the post execution scripts the best way to go about this?

      • If the clustered index is different on the subscriber than the publisher am I best to allow the bulk insert to happen with the publisher clustered index or would it be better to set the alternate clustered index before the bulk insert?


      Thanks in advance for any help.










      share|improve this question














      Just a preface that I'm working at the moment as an accidental DBA so sorry for any ignorance.



      I need to completely rebuild one of our transactional replications. The indexing strategy is different on the subscriber database than it is on the publisher, the primary key is the same but the clustered index on NC indexes are different. I am aware that the tables by default are completely dropped on the subscriber. I believe I can use scripts pre and post snapshot application to drop and create indexes.



      Both the clustered indexes on the subscriber and publisher are UniqueIdentifier but different columns. The table has nearly 1 billion rows and is sadly pretty wide. Just thought that I'd provide that information in case it makes a difference.



      My questions are:




      • Is using the post execution scripts the best way to go about this?

      • If the clustered index is different on the subscriber than the publisher am I best to allow the bulk insert to happen with the publisher clustered index or would it be better to set the alternate clustered index before the bulk insert?


      Thanks in advance for any help.







      sql-server sql-server-2008-r2 transactional-replication






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 8 '17 at 12:59









      Bee_RiiiBee_Riii

      255




      255





      bumped to the homepage by Community 5 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 5 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          In my opinion, because of the table size the better way is use the strategy truncate table in the publication options and use pre script to create all index before to proceed with the load.



          Two other question:



          It's work? I mean this replication was synchronized with more the 1 bilion rows? At my work a have problems to replicated table with more the 300 milions rows.



          Is this table was partitioned? With this size I really recommended that.






          share|improve this answer





















          • 1





            Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

            – Bee_Riii
            Jun 8 '17 at 15:16











          • @Bee_Riii I corrected my answer.

            – Krismorte
            Jun 8 '17 at 15:30












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f175770%2ftransactional-replication-pre-and-post-scripts%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          In my opinion, because of the table size the better way is use the strategy truncate table in the publication options and use pre script to create all index before to proceed with the load.



          Two other question:



          It's work? I mean this replication was synchronized with more the 1 bilion rows? At my work a have problems to replicated table with more the 300 milions rows.



          Is this table was partitioned? With this size I really recommended that.






          share|improve this answer





















          • 1





            Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

            – Bee_Riii
            Jun 8 '17 at 15:16











          • @Bee_Riii I corrected my answer.

            – Krismorte
            Jun 8 '17 at 15:30
















          0














          In my opinion, because of the table size the better way is use the strategy truncate table in the publication options and use pre script to create all index before to proceed with the load.



          Two other question:



          It's work? I mean this replication was synchronized with more the 1 bilion rows? At my work a have problems to replicated table with more the 300 milions rows.



          Is this table was partitioned? With this size I really recommended that.






          share|improve this answer





















          • 1





            Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

            – Bee_Riii
            Jun 8 '17 at 15:16











          • @Bee_Riii I corrected my answer.

            – Krismorte
            Jun 8 '17 at 15:30














          0












          0








          0







          In my opinion, because of the table size the better way is use the strategy truncate table in the publication options and use pre script to create all index before to proceed with the load.



          Two other question:



          It's work? I mean this replication was synchronized with more the 1 bilion rows? At my work a have problems to replicated table with more the 300 milions rows.



          Is this table was partitioned? With this size I really recommended that.






          share|improve this answer















          In my opinion, because of the table size the better way is use the strategy truncate table in the publication options and use pre script to create all index before to proceed with the load.



          Two other question:



          It's work? I mean this replication was synchronized with more the 1 bilion rows? At my work a have problems to replicated table with more the 300 milions rows.



          Is this table was partitioned? With this size I really recommended that.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 8 '17 at 15:28

























          answered Jun 8 '17 at 15:00









          KrismorteKrismorte

          414212




          414212








          • 1





            Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

            – Bee_Riii
            Jun 8 '17 at 15:16











          • @Bee_Riii I corrected my answer.

            – Krismorte
            Jun 8 '17 at 15:30














          • 1





            Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

            – Bee_Riii
            Jun 8 '17 at 15:16











          • @Bee_Riii I corrected my answer.

            – Krismorte
            Jun 8 '17 at 15:30








          1




          1





          Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

          – Bee_Riii
          Jun 8 '17 at 15:16





          Yeah it works. It takes about 6 hours to process the snapshots and then another few hours to rebuild the indexes. Unfortunately we don't have enterprise so I can't partition it unless we did a partitioned view but we often query all over the range so from what I understand a partitioned view would be quite slow. So your suggestion would be to drop the nonclustered indexes, Truncate the table and let it insert with the current clustered index in place then add the nonclustered indexes again? Just making sure I'm clear. Thanks

          – Bee_Riii
          Jun 8 '17 at 15:16













          @Bee_Riii I corrected my answer.

          – Krismorte
          Jun 8 '17 at 15:30





          @Bee_Riii I corrected my answer.

          – Krismorte
          Jun 8 '17 at 15:30


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f175770%2ftransactional-replication-pre-and-post-scripts%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Parapolítica Índice Antecedentes El escándalo Proceso judicial Consecuencias Véase...

          How to remove border from elements in the last row?Targeting flex items on the last rowHow to vertically wrap...

          Tecnologías entrañables Índice Antecedentes Desarrollo Tecnologías Entrañables en la...