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

Issue with Replication Latency with computed columns

$
0
0

We have transactional replication enabled and there are 15 tables that are replicated. Out of 15 there are 6 tables where we have computed columns that are persisted. When ever there are several writes, if the actual transaction size is 100 MB on the publisher, the log reader agent is queuing up almost 30-40 GB of data and the latency is significantly increasing and the transaction log is getting held up by REPLICATION in log_reuse_wait. 

An example schema for a table is

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[address](
	[address_id] [int] IDENTITY(1,1) NOT NULL,
	[crm_entity_id] [int] NOT NULL,
	[address_title] [varchar](600) NOT NULL,
	[address1] [varchar](300) NULL,
	[address2] [varchar](300) NULL,
	[address3] [varchar](300) NULL,
	[city] [varchar](300) NULL,
	[state_name] [varchar](15) NULL,
	[state_non_roman] [varchar](300) NULL,
	[postal_code] [varchar](60) NULL,
	[district] [varchar](15) NULL,
	[country] [varchar](15) NULL,
	[country_non_roman] [varchar](150) NULL,
	[non_roman] [char](1) NOT NULL,
	[is_primary] [char](1) NOT NULL,
	[parent_address_id] [int] NULL,
	[vat_supply_to] [char](1) NOT NULL,
	[created_by] [char](8) NOT NULL,
	[created_time] [datetime] NOT NULL,
	[modified_by] [char](8) NOT NULL,
	[modified_time] [datetime] NOT NULL,
	[address_title_uni]  AS (case when [address_title] IS NULL then NULL else CONVERT([nvarchar](200),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](600),[address_title],0)),0) end) PERSISTED,
	[address1_uni]  AS (case when [address1] IS NULL then NULL else CONVERT([nvarchar](100),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](300),[address1],0)),0) end) PERSISTED,
	[address2_uni]  AS (case when [address2] IS NULL then NULL else CONVERT([nvarchar](100),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](300),[address2],0)),0) end) PERSISTED,
	[address3_uni]  AS (case when [address3] IS NULL then NULL else CONVERT([nvarchar](100),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](300),[address3],0)),0) end) PERSISTED,
	[city_uni]  AS (case when [city] IS NULL then NULL else CONVERT([nvarchar](100),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](300),[city],0)),0) end) PERSISTED,
	[state_non_roman_uni]  AS (case when [state_non_roman] IS NULL then NULL else CONVERT([nvarchar](100),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](300),[state_non_roman],0)),0) end) PERSISTED,
	[postal_code_uni]  AS (case when [postal_code] IS NULL then NULL else CONVERT([nvarchar](20),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](60),[postal_code],0)),0) end) PERSISTED,
	[country_non_roman_uni]  AS (case when [country_non_roman] IS NULL then NULL else CONVERT([nvarchar](50),[dbo].[udfVarBinaryToUTF16](CONVERT([varbinary](150),[country_non_roman],0)),0) end) PERSISTED,
 CONSTRAINT [pk_address] PRIMARY KEY CLUSTERED
(
	[address_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[address]  WITH CHECK ADD  CONSTRAINT [fk_address] FOREIGN KEY([crm_entity_id])
REFERENCES [dbo].[crm_entity] ([crm_entity_id])
GO

ALTER TABLE [dbo].[address] CHECK CONSTRAINT [fk_address]
GO

ALTER TABLE [dbo].[address]  WITH CHECK ADD  CONSTRAINT [fk_address2] FOREIGN KEY([parent_address_id])
REFERENCES [dbo].[address] ([address_id])
GO

ALTER TABLE [dbo].[address] CHECK CONSTRAINT [fk_address2]
GO


Viewing all articles
Browse latest Browse all 4054

Trending Articles



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