Transactional replication very slow with indexes on Subscriber table

  • I have setup Transactional Replication for one of our databases where one table with about 5mln records is replicated to a Subsriber database. With every replication about 500-600.000 changed records are send to the Subscriber.

    Since one month I see very strange behaviour when I add about 10 indexes to the Subscriber table. As soon as I have added the indexes replication speed becomes extremely slow (almost 3 hours for 600k records). As soon as I remove the indexes the replication is again very fast, about 3 minutes for the same amount of records.

    I've searched a lot on the internet to solve this issue but can't find any explaination for this strange behaviour after adding the indexes. As far as I know it doesn't have to be a problem to add indexes to a Subscriber table, and it hasn't been before on another replication configuration we use.

    Some information from the Replication Log:

    With indexes on the Subscriber table

    --------------------------------------

    Total Run Time (ms) : 9589938 Total Work Time : 9586782

    Total Num Trans : 3 Num Trans/Sec : 0.00

    Total Num Cmds : 616245 Num Cmds/Sec : 64.28

    Total Idle Time : 0

    Writer Thread Stats

    Total Number of Retries : 0

    Time Spent on Exec : 9580752

    Time Spent on Commits (ms): 2687 Commits/Sec : 0.00

    Time to Apply Cmds (ms) : 9586782 Cmds/Sec : 64.28

    Time Cmd Queue Empty (ms) : 5499 Empty Q Waits > 10ms: 172

    Total Time Request Blk(ms): 5499

    P2P Work Time (ms) : 0 P2P Cmds Skipped : 0

    Reader Thread Stats

    Calls to Retrieve Cmds : 2

    Time to Retrieve Cmds (ms): 10378 Cmds/Sec : 59379.94

    Time Cmd Queue Full (ms) : 9577919 Full Q Waits > 10ms : 6072

    Without indexes on the Subscriber table

    --------------------------------------

    Total Run Time (ms) : 89282 Total Work Time : 88891

    Total Num Trans : 3 Num Trans/Sec : 0.03

    Total Num Cmds : 437324 Num Cmds/Sec : 4919.78

    Total Idle Time : 0

    Writer Thread Stats

    Total Number of Retries : 0

    Time Spent on Exec : 86298

    Time Spent on Commits (ms): 282 Commits/Sec : 0.03

    Time to Apply Cmds (ms) : 88891 Cmds/Sec : 4919.78

    Time Cmd Queue Empty (ms) : 1827 Empty Q Waits > 10ms: 113

    Total Time Request Blk(ms): 1827

    P2P Work Time (ms) : 0 P2P Cmds Skipped : 0

    Reader Thread Stats

    Calls to Retrieve Cmds : 2

    Time to Retrieve Cmds (ms): 2812 Cmds/Sec : 155520.63

    Time Cmd Queue Full (ms) : 86032 Full Q Waits > 10ms : 4026

    Can someone please help me with this issue? Any ideas?

    Pim

  • It makes sense to me that adding indexes would greatly slow down replication. Think about it, for each index SQL Server has to make a copy of the data for the columns used in the index. So you are doing a lot more writes than you would be without indexes.

  • Thanks for your response. I understand that adding indexes will add some extra time to replicate all records. But an increase of >10000% ?

    As you see in the log there are 4919 command/sec when writing without indexes and only 64 commands/sec with indexes on the Subscriber table. It's a huge difference and I really can't believe this has only to do with the indexes.

    We had exactly the same replication set before on another server where the indexes added a few minutes to the replication time, but not a difference of almost 3 hours(!). So I really think the error has to be somewhere else:(

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply