locked
Batch and Snapshot to client RRS feed

  • Question

  • Using Snapshot to client, i don't want to change any schema on client or server. I am also using BatchSize=20

    How do I modify the sample usp_GetNewBatchAnchor since I am not using update or inserttimestamps.
    Can I just change the section in Bold Below  to say this instead :

       IF @sync_last_received_anchor IS NULL OR @sync_last_received_anchor = 0
    
           BEGIN
    
     
    set @sync_last_received_anchor = 0
    
    		END
    
    

    ?
    CREATE PROCEDURE [dbo].[usp_GetNewBatchAnchor] (
    
    	@sync_last_received_anchor timestamp, 
    
    	@sync_batch_size bigint,
    
    	@sync_max_received_anchor timestamp out,
    
    	@sync_new_received_anchor timestamp out,            
    
    	@sync_batch_count int output)            
    
    AS            
    
           -- Set a default batch size if a valid one is not passed in.
    
           IF  @sync_batch_size IS NULL OR @sync_batch_size <= 0
    
    	     SET @sync_batch_size = 1000    
    
    
    
    	   -- Before selecting the first batch of changes,
    
    	   -- set the maximum anchor value for this synchronization session.
    
           -- After the first time that this procedure is called, 
    
    	   -- Synchronization Services passes a value for @sync_max_received_anchor
    
           -- to the procedure. Batches of changes are synchronized until this 
    
           -- value is reached.
    
           IF @sync_max_received_anchor IS NULL
    
             SELECT  @sync_max_received_anchor = MIN_ACTIVE_ROWVERSION() - 1
    
           
    
           -- If this is the first synchronization session for a database,
    
           -- get the lowest timestamp value from the tables. By default,
    
           -- Synchronization Services uses a value of 0 for @sync_last_received_anchor
    
           -- on the first synchronization. If you do not set @sync_last_received_anchor,
    
           -- this can cause empty batches to be downloaded until the lowest
    
           -- timestamp value is reached.
    
           IF @sync_last_received_anchor IS NULL OR @sync_last_received_anchor = 0
    
           BEGIN
    
                    
    
    		SELECT @sync_last_received_anchor = MIN(TimestampCol) FROM (
    
    		  SELECT MIN(UpdateTimestamp) AS TimestampCol FROM Sales.Customer
    
    		  UNION
    
    		  SELECT MIN(InsertTimestamp) AS TimestampCol FROM Sales.Customer
    
    		  UNION
    
    		  SELECT MIN(UpdateTimestamp) AS TimestampCol FROM Sales.OrderHeader
    
    		  UNION
    
    		  SELECT MIN(InsertTimestamp) AS TimestampCol FROM Sales.OrderHeader
    
    		) MinTimestamp	
    
           
    
    		SET @sync_new_received_anchor = @sync_last_received_anchor + @sync_batch_size
    
    
    
    		-- Determine how many batches are required during the initial synchronization.
    
    		IF @sync_batch_count <= 0
    
    		  SET @sync_batch_count = ((@sync_max_received_anchor / @sync_batch_size) - (@sync_last_received_anchor /  @sync_batch_size))
    
    
    
    		END
    
    
    
           ELSE
    
           BEGIN
    
    
    
            SET @sync_new_received_anchor = @sync_last_received_anchor + @sync_batch_size
    
    
    
            -- Determine how many batches are required during subsequent synchronizations.
    
    		IF @sync_batch_count <= 0
    
              SET @sync_batch_count = ((@sync_max_received_anchor / @sync_batch_size) - (@sync_new_received_anchor /  @sync_batch_size)) + 1  
    
           
    
    	   END
    
    
    
           -- Check whether this is the last batch.      
    
           IF @sync_new_received_anchor >= @sync_max_received_anchor
    
           BEGIN
    
    
    
             SET @sync_new_received_anchor = @sync_max_received_anchor        
    
             IF @sync_batch_count <= 0
    
               SET @sync_batch_count = 1
    
    
    
           END
    
    



    • Moved by Hengzhe Li Friday, April 22, 2011 3:06 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, June 9, 2009 12:35 AM

All replies

  • Hi,

    what do you use instead update or inserttimestamps?


    And a general questions to all...

    What differs, in your opinion, batching to the usual paging szenarios?



    Regards,

    Martin
    Tuesday, June 9, 2009 7:48 AM