Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

Ability to use Query hint in Transactional Replication filtered articles

$
0
0

Really frustrated with this piece and hence sharing my experience with the product team.
I am setting up filtered replication(tran repl) for a table that is 2+ TB in size. The filtered rows are less than 1% of total size.

When I run the snapshot, sometimes it complete in 27 mins(I have already optimized the snapshot agent profile) and sometimes it runs for ever. Mostly it runs forever, so the chances of it finishing soon are really very less.

I have infact created filtered index just to cater to the query in the filter i.e. on the filter predicates. The reason its flipping flopping is due to the incorrect plan that it chooses. I can force the right index and the filtered query runs just fine but I cannot use the query hints when I am adding the filter in replication as its not allowed.

I then went ahead and created the plan guides to force the best plan. But the plan guide was not used because even if there is a single space in the actual query that replication runs in the background the plan guide will not be used(testing on plan guides has proved this).

The query needs to be ditto same including whitespaces and carriage returns. I then ran profiler and found that there is a view that replication creates and executes to extract the filtered rows and BCP it. Got the text of the view and created the plan guide on it but it was still not used because sp_helptext output seems to be different than what is actually being fired by replication internally.

Further, I collected the verbose log with level 2 and tried to find out if the main query shows up there with no success. So now I'm stuck. I know the solution but I cannot use it because:
(a) I can't use the plan guide because I do not know the exact syntax(I mean I have the query but I do not know the white spaces, carriage returns, etc) and
(b) I cannot use query hint while filtering the article.

1. I cannot afford to have downtime.
2. I cannot use backup and restore option either.

Submitted the feature request on connect as well:

https://connect.microsoft.com/SQLServer/feedback/details/1577872/ability-to-use-query-hint-in-transactional-replication-filtered-articles


Abhay Chaudhary OCP 9i, MCTS/MCITP (SQL Server 2005, 2008, 2005 BI) ms-abhay.blogspot.com/


Viewing all articles
Browse latest Browse all 4054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>