Thursday, September 14, 2017

No hidden columns in sql server

Unfortunately this feature isnt available yet.
There is no way to hide a column in sql server, hope Microsoft adds this soon.

Wednesday, March 9, 2016

HADR_SYNC_COMMIT wait types in sql server 2012 Always on

Found this recently in our environment:

whenever rebuild index job is running (with online or without), all the application connections are timing out and the wait types show as below
HADR_SYNC_COMMIT

found that this is a bug in Always on  Availability groups when Synchronous mode is used.
To alleviate this, switch to Async mode, do your rebuild indexes and then switch back to Sync mode.

Tuesday, January 13, 2015

Resolve frequent deadlocks and blocks in sql server if the problem is due to lock escalation


This is a long investigation ( though i mentioned it in a few lines )and should be done carefully.

you get very frequent deadlocks in your system (you would know by enabled 1204 or 1222 trace flags) or by adding 'deadlock related events' in your extended events or by tracking 'deadlock information' using 'typeperf' performance counters.
Also you see frequent blocks happening and most of these point to a few tables.

And if you think all these are happening because of lock escalation then:

1) trace 'lock escalation' performance counter to check how frequently lock escalation is happening, at the same time you can add 'lock escalation' related event (eventid=60) to your extended events and track the actual objects where lock escalation is happening

once you get the culprits, then its easy
if it is because of lock escalation then disable it
alter table <table name> set (lock_escalation=disable)
if you know the off/on peak loads for your application, then play with disable/enable depending on your performance



Tuesday, August 26, 2014

how to check when was the successful DBCC CheckDB run in sql server

its simple.

dbcc dbinfo ('db1') with tableresults
and then check for "dbi_dbcclastknowngood" field.

you can also get a host of other fields and values from dbinfo command.

Also the below command gets you the same answer:

dbcc page (dbname,1,9,3) with tableresults

Tuesday, May 20, 2014

Some new DMVs and new views and functions in sql server 2012


select * from sys.dm_server_services

select * from sys.dm_server_registry

select * from sys.dm_os_windows_info  - gives the service pack level and windows version, won't exactly say whether it is win 2008 or 2012, we have to figure this out by comparing with the release number

select * from sys.database_recovery_status

select * from sys.dm_clr_properties  - gives the .net CLR version

select * from sys.dm_clr_loaded_assemblies

select * from [sys].[dm_db_fts_index_physical_stats]  - for fulltext indexes

select * from [sys].[dm_db_log_space_usage]  - no need of dbcc sqlperf now

select * from [sys].[dm_tcp_listener_states]

select * from [sys].syslockinfo

select * from sys.all_sql_modules  - gives scripts of all views, sps and functions