SQL Server

Event Sourcing: Optimizing NEventStore SQL read performance

In my previous post about Event Store read complexity I described how the growth of reads from the event database might be quadratic in respect to amount of events per aggregate.

Read more...

T-SQL MERGE statement is underrated

How many times did you write a SQL to save a row without knowing whether the same primary key already exists or not? You just get an object in your data access layer and you want to save all fields into the database.

Read more...

How I fixed a bug in SQL Server

Our production databases were migrated from SQL Server 2012 to SQL Server 2014. Among other improvements in the latter, the new cardinality estimator was introduced. The new estimator is supposed to be smarter than the old one, of course. It takes more factors into account, and thus should give better results with some query plans. But "new" also means "less tested"...

Read more...

Nice way to kill your SQL Server

The short story about how to crash your complete system by missing one line of code in SQL Server stored procedure.

Read more...

SQL: produce resultset with N rows

Sometimes you need to produce a result set, which would contain N rows with numbers 1...N in each row. For example, I needed to calculate some statistics per week for N weeks starting from today and going back to the past.

Read more...