Speaking at Advanced Technology Days 2016

atd12
Congratulations! Your session Show me the cache! has been accepted for Advanced Technology Days 12!
http://atd.mscommunity.hr/predavanja/#session_61

It will be interesting exploration of SQL Server’s caches, especially the most important ones: plan cache and buffer pool cache, Memory Optimized tables and Columnstore Indexes.

Come, mingle, learn. It will be fun and you will increase your knowledge and value.

Posted in Conferences

Database Recovery from RAM

Introduction

Recently I had a client who basically lost his SQL Server databases. I decided to share this experience with you, so you can use it if you ever find yourself in so tough situation. The client found out that backup job was failing and it was failing undiscovered for quite some time. The moment they found that out was the moment when their RAID array failed and corrupted the database files. Application started to throw IO errors at users. Storage failed, files unreadable and no backups – time for me to do my magic! Read more ›

Posted in Transaction log and Recovery

Formatting TSQL code

How do I format my TSQL code?

Everybody has it’s own preferences on formatting SQL or TSQL code. I follow few very simple rules to achieve better readability, less bugs and  – you wont’ believe – faster code execution! Code that is not using two-part names will compile a separate execution plan for each user. Therefore taking more memory than it would when using two-part names. More compiles means more wasted CPU, more latches and compile locks. Latches and locks are serialization mechanisms. They make things execute one-by-one (not in parallel), making your 100 core monster perform like a poor single core machine.

Read more ›

Posted in TSQL and SQL Client Code

Speaking at conference Kulendayz 2015

4th of September I will hold a full-day preconference training about SQL Server 2016 performance tuning. It will be different, interesting, and hopefully funny. Real-life examples, way of thinking about the performance, and what are the ultimate limits of physical world we know of and how to approach them with SQL 2016. Prepare for no dry-talk, and to get involved in discussion. There are only 2 weeks left, so ask your boss and reserve your seat here: the link.

The next day I also have a lecture about one simple method of tracking performance history and trends. There are also many other very interesting sessions, not just for SQL Server people, but also for Web Developers, Admins, team and project leaders, about Microsoft and cloud technologies. Here is the complete agenda.

IMG_5011-2

Kulendayz2014logo

Posted in Conferences

RCSI and LOB data – how tempdb version store is used?

Row Version Store

We know RCSI (Read Committed Snapshot Isolation), as well as SI (Snapshot Isolation) use row versioning to store previous verions of rows in part of tempdb called “row version store”. If you are using default isolation level RC (Read Committed) and think that you are not using row versioning and version store at all – you are wrong! From SQL 2005 version store is used to store previous row versions for tables with triggers (“deleted” special pseudo-table rows are there) and online index (re)builds. Row versions which are not needed anymore are cleaned up periodically from tempdb.

Query the space version store uses within the tempdb:

 LOB (BLOB, CLOB) and row versioning

The question arised from my colleague SQL Master Denny Cherry (@mrdenny), are also BLOBs previous versions stored in tempdb? By LOB we think of large data types stored in separate allocation unit called LOB_DATA. For example “MAX” types (VARCHAR(MAX), VARBINARY(MAX) NVARCHAR(MAX)), XML, plus old deprecated types like TEXT and IMAGE. The short answer is: yes, old versions of LOBs are also stored in row version store! Let us prove it:

 Summary

SQL Server uses version store in tempdb to store old version of the row, not just IN_ROW_DATA, but also LOB_DATA and ROW_OVERFLOW_DATA allocation units. It is used for DELETE and UPDATE statements, but NOT for INSERT (since there is no “old” row to store when you insert a new one). Strangely, version store allocates twice the size of old (deleted/updated) version of the row. Therefore, beware of UPDATE and DELETEs of the LOBs in RCSI isolation, they might take a huge amount of version store space!

Posted in Uncategorized

Page Life Expectancy and 300 sec limit

People blogged about it, including excellent Jonathan’s post here (highly recommended to read), but I will give a little more insight here. Basically, Microsoft says if PLE is below 300 seconds, we should worry about memory pressure (an old recommendation from 2006. still appearing today here and there). Jonathan shows how 300 sec threshold is obsolete, and that it should be per every 4GB of RAM. That makes a big difference on current servers which have much more RAM than 4GB. I will split it down to the NUMA node level, because today’s servers not only have plenty of RAM, but also plenty of CPU’s which are grouped into NUMA nodes, and so is the memory divided into memory nodes.

That means the PLE limit is better calculated per memory node. If we calculate it globally, it might hide the fact that a single memory node falls way below the treshold, because other numas are in good standing, healthy. If we look only global PLE we will not notice that one numa node’s PLE is not ok.

Read more ›

Posted in Uncategorized

Speaking at SQL Saturday Budapest #sqlsatbudapest

I just returned from Sql Saturday 376 in Budapest (#sqlsatbudapest).
It was really amazing. The conference room I held presentation was huge and to my pleasant surprise – fully packed!
I got a lot of positive comments there, so at least no one was sleeping 😉
The speaker’s dinner the day before was really really fun.
Especially Mladen Prajdić’s birthday we celebrated with a cake. We didn’t bother with the fact that it really wasn’t his birthday. We needed an excuse to eat a cake so we ordered one 😉

IMG_5450

IMG_5455

Link to my lecture.

Posted in Conferences

CommandTimeout – How to handle it properly – code example

Properly closing a connection to Sql Server in DotNet is more challenging than one might think. Classic code looks something like this MSDN example:

Read more ›

Posted in TSQL and SQL Client Code Tagged with: , ,

CommandTimeout – How to handle it properly?

ADO.Net Data Provider for SQL Server (System.Data.SqlClient namespace in System.Data.dll assembly) has two common classes we often use: SqlConnection and SqlCommand. SqlCommand class has CommandTimeout property (do not mix it with the ConnectionTimeout which stops long login process). But, do we handle it properly? And what exactly is happening when the command timeout occurs?

Read more ›

Posted in TSQL and SQL Client Code Tagged with: ,

Speaking at SQL Saturday Vienna conference

sqlsat374_web

I am pleased that I will speak at SQL Saturday conference in Vienna, 28th of February 2015 about how to solve the “recovery impossible” situation. It is quite advanced topic, but everyone who listens will be able to save the data and retrieve the “lost” part later, even when the database is in SIMPLE recovery model and no backups exist.
It looks like magic, but there is a science and logic (and SQL Server internals knowledge) behind it.
But what I am looking forward the most is to meet you, the great people, and socialize. Last time in Ljubljana it was so fun and very useful, and I am confident that it will be in Vienna too. There are quite interesting topics, and the event is free, so register if not already because seats are limited and filled quickly.

See you there!

Posted in Conferences
Visit Us On TwitterVisit Us On FacebookVisit Us On LinkedinVisit Us On YoutubeVisit Us On Google PlusCheck Our Feed