Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 Hierarchy Data Type Performance?

How does SQL Server 2008's Hierarchy data type perform compared to using the hierarchy implementation described by Joe Celko here: http://www.intelligententerprise.com/001020/celko.jhtml?

I've used Celko's method in the past with great results - but don't want to implement it for a new project unless it's better than what Microsoft has provided in SQL Server 2008.

like image 227
nikmd23 Avatar asked Jun 25 '09 19:06

nikmd23


People also ask

What are the restrictions of hierarchy data types?

Limitations of hierarchyid The hierarchyid data type has the following limitations: A column of type hierarchyid doesn't automatically represent a tree. It is up to the application to generate and assign hierarchyid values in such a way that the desired relationship between rows is reflected in the values.

Which data type can be used to represent position in a hierarchy in SQL?

The hierarchyid data type is a variable length, system data type. Use hierarchyid to represent position in a hierarchy.

What is Hierarchyid data type in SQL Server?

SQL Server hierarchyID is a built-in data type designed to represent trees, which are the most common type of hierarchical data. Each item in a tree is called a node. In a table format, it is a row with a column of hierarchyID data type. Usually, we demonstrate hierarchies using a table design.


1 Answers

So far, I've only found a single reasonably interesting article on the topic. HierarchyId is much faster than any self-made self-referencing table solution:

http://www.sqlservercentral.com/articles/SQL+Server+2008/62204/

I vaguely remember seeing another comparison elsewhere (but can't find it anymore) which came to similar conclusions; using HierarchyId to build up the hierarchy is a bit cumbersome at best, but query performance is stellar.

Marc

like image 112
marc_s Avatar answered Oct 06 '22 00:10

marc_s