Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server 2005 XML Datatype David Wilson Ohio North SQL Server Special Interest Group July 12, 2007.

Similar presentations


Presentation on theme: "SQL Server 2005 XML Datatype David Wilson Ohio North SQL Server Special Interest Group July 12, 2007."— Presentation transcript:

1 SQL Server 2005 XML Datatype David Wilson Ohio North SQL Server Special Interest Group July 12, 2007

2 Agenda Background Testing Goals Indexing Results Query Results References

3 Background Why XML in a database?  Semi-structured data  Ease of Development  Manageability

4 Background SQL Customer Lab  What initiated the testing?  Why Redmond?

5 Background XML Data type Indexes  Primary  Secondary Path Property Value XML Schemas

6 Background Element versus Attribute centric XML  Element 3 1234567  Attribute

7 Testing Goals xQuery vs T-SQL vs. hybrid queries Determine the feasibility of creating xQuery based views Evaluate the use of XML schemas Determine indexing strategy Greater understanding of the XML Datatype

8 Testing Methodology Loaded 1 million Policy versions created in element and attribute centric formats Suite of easy, medium and hard queries in T-SQL, xQuery, mixed and against views Space, performance and time statistics gathered for tests

9 Results: Attribute vs Element

10 Indexing Results Creation of Primary Index is not a parallel operation

11 Indexing Results Optimal indexes were 2.7 times the data size

12 Indexing Results Keep the number of attributes as low as possible

13 Who here worked with SQL 6.5?

14 Query Performance

15 xQuery performance varies greatly depending on quality of query  Explicitly convert predicates to strings  Use nodes method in the FROM clause  Group fragment values together in the SELECT clause  Use the exist() method on the XML data type whenever possible, instead of the value() method

16 Query Performance When comparing the same XML attribute to multiple values in a WHERE clause, list the name of the attribute on the outside of the predicate. For example, instead of this: WHERE PolicyXMLFragment.exist (' /Fields[@pol_dt >= 20061201 and @pol_dt <= 20061231] ') = 1 The XQuery should be written as this: WHERE PolicyXMLFragment.exist (' @pol_dt[. >= "20061201" and. <= "20061231"] ') = 1

17 Query Performance T-SQL outperforms xQuery Avoid views over xQuery  Different query processors result in large amounts of data being moved between steps Where possible use T-SQL predicates to narrow down scope of xQuery

18 References XML Best Practices  http://msdn2.microsoft.com/en-us/library/ms187508.aspx XML Support in SQL 2005  http://msdn2.microsoft.com/en-us/library/ms345117.aspx XML Data Type Performance Optimizations  http://msdn2.microsoft.com/en-us/library/ms345118.aspx SQL Server 2005 XML  http://msdn2.microsoft.com/en-us/sql/aa336361.aspx


Download ppt "SQL Server 2005 XML Datatype David Wilson Ohio North SQL Server Special Interest Group July 12, 2007."

Similar presentations


Ads by Google