Code Reviews – What good are they for?

All database changes go through me. 
Do or Review, do or review.

These have been my catch phrases since taking on the lead SQL developer role at my company, on my team.  There have many changes that I’ve had to review – many, many changes, most of them are fine, but occasionally I get a [...]

Big Trys and Small Trans

The catch phrase around the office these days is “Big Trys and small Trans.”  This came about as we were review stored procedure changes and I two suggestions.  First, that the entire procedure has a try…catch around it and second that the transaction be as small as possible.

Big Try

We’ve got standards in place [...]

SQL Performance Trouble Shooting – the basics from Microsoft

Check Activity Monitor

Anything running?
Blocking/wait times
Goto Locks and check lock strategy

SQL Error Log

Any errors? If so investigate

Resource utilizations

DMVs

sys.dm_exec_query_stats

Look at: Total physical reads, logical reads, number to executions, total time, (divide those two to get average)
Join with sys.dm_exec_sql_text

Performance Monitors

Processor Time
Memory
SQL Server Statistics

Batch requests/sec
Compilations
Recompilations – high CPU time (use fully qualified name to avoid recompiatoins)

SQL Wait stats
SQLServer [...]

Get Fairly Accurate Table Counts

This is the fast way to get a count of all the data in the tables in a database…

SELECT [TableName] = so.name, [RowCount] = MAX(si.rows)FROM sysobjects so, sysindexes siWHERE so.xtype = ‘U’AND si.id = OBJECT_ID(so.name)GROUP BY so.nameORDER BY 2 DESC

Weekly Challenges 4/25/08

Here’s this week’s weekly challenges….

New release went out last Friday, 4/18/08 – lots and lots of SQL servers

Two SQL 2005 Clustered 64 bit
Two SQL 2005 64 bit Log Shipping servers
Three SQL 2005 Utility servers
Eight SQL 2005 Express servers
One SQL 2000 utility server

I spent most of the week in in the “War” room with a consultant [...]

Tuning sys.dm_db_index_physical_stats

We had a report that was using sys.dm_db_index_physical_stats to find partition progress information. It was taking 45 minutes reguardless of the data in the results. We started looking at the data it was reading. The slow down was around two tables with LOB_Data in them. One table had about 14 million [...]