2012中创建了Identity的表,定义如下:  

 

createtable testidentity(idintidentity(1,1),name varchar(10))

 

插入10条测试数据:

 

insertinto testidentity values ('a')

go 10

 

Failover之后发现Identity的值变为了1001.

 

selectIDENT_CURRENT('testidentity')

 

插入十条记录结果:

 

SQL Server 2012 AlwaysOn Group 使用 Identity字段注意事项

 

由于SQL ServerCash identity 的值,所以可能会有Gap(比如rollback/restart),但是不应该这么大。

 

解决这个办法要使用Trace Flag 272:

 

SQL Server 2012 AlwaysOn Group 使用 Identity字段注意事项

 

注意:Thiswill cause a log record to be generated for each generated identity value. Theperformance of identity generation may be impacted by turning on this traceflag

 

也就意味着使用这个TraceFlag有额外的性能开销,如果Identity使用非常频繁的话注意。

 

另外可以考虑NO CACHE的方式,比如http://msdn.microsoft.com/en-us/library/ff878091.aspx

 

转载于:https://blog.51cto.com/lzf328/1349456

相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2021-08-17
  • 2021-12-02
  • 2021-04-14
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2021-04-09
  • 2021-07-11
  • 2021-09-26
  • 2022-12-23
  • 2021-12-17
相关资源
相似解决方案