Database

Ready, SET, go – how does SQL server handle recursive CTE’s

Posted on

First of all, a quick recap on what a recursive query is. Recursive queries are useful when building hierarchies, traverse datasets and generate arbitrary rowsets etc. The recursive part (simply) means joining a rowset with itself an arbitrary number of times. A recursive query is defined by an anchor set (the base rowset of the recursion) and a recursive part (the operation that should be done over the previous rowset). This blogpost will cover some of the basics in recursive CTE’s and explain the approach done by the SQL Server engine.

Database

Use of hierarchyid in SQL Server

Posted on

I attended a TDWI conference in May 2016 in Chicago. Here I got a hint about the datatype hierarchyid in SQL Server which could optimize and eliminate the good old parent/child hierarchy. Until then I (and several other in the class) hadn’t heard about the hierarchyid datatype in SQL Server. So here’s an article covering some of the aspects of the datatype hierarchyid – including: Introduction How to use it How to optimize data in the table How to work with data in the hierarchy-structure Goodies Introduction The datatype hierarchyid was introduced in SQL Server 2008. It is a variable […]

BIML

Enlarge AdventureWorksDW2012

Posted on

Just recently I had to have a big datawarehouse solution to test some performance optimization using BIML. I could use the AdventureWorks2012 database, but I needed the clean datawarehouse tables in order to have minimum data maintennance when testing the BIML scripts. I could not find it, and figures out it was faster to make my own. So heavily inspired by this post from Jonathan Kehayias (blog), I’ve made a script that can be used to enlarge the dbo.FactInternetSales table. The script creates a new table called dbo.FactInternetSalesEnlarged and copies data from dbo.FactInternetSales into it with a randomizer. Exploding the […]

Database

SQL 2012: Performance monitoring the light and right way

Posted on

Ever had that awesome SQL tracer build up that does just the right thing for your system – well I know that I had. And someday you might need just the same trace again. But now you need to build it again… Here comes the feature Extended Events in place. It was first introduced in the SQL 2008 version. The feature is a good and lightweight event-driven mechanism for collecting information about your SQL server.