Michael Rys

Musings on XML, XQuery and more...

<January 2009>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567


Navigation

Papers

SQL Server XML Whitepapers

Weblogging Links

MS Bloggers

Recommended Books

Other Blogs

Recommended Links

Presentations (Upcoming)

Presentations (Recent)

Subscriptions

News


Upcoming Presentations


TechEd 2007, Orlando, June 4 to June 8, 2007


Books I co-authored



www.flickr.com
This is a Flickr badge showing public photos from Michael Rys. Make your own badge here.
eXTReMe Tracker

Post Categories

Article Categories



MSDN WebCast Demo: XML Indexing

-- Indexing of an XML datatype column
-- Execute every statement in the sample in order
-- Follow links to see estimated query plans
-- (c) 2004, 2005 Microsoft Corp.

USE msdn2005;
GO

-- Run a query (look at estimated query plan)
SELECT doc
FROM
XMLdoc
WHERE 1 = doc.exist
(
 
'declare default element namespace "urn:example/customer";
  /doc/customer[order/@year>2000]
'
);
GO

-- Create primary XML Index
CREATE PRIMARY XML INDEX PrimXIdxXMLdoc ON XMLdoc(doc);
GO

-- Run query again (look at estimated query plan again)
SELECT doc
FROM
XMLdoc
WHERE 1 = doc.exist
(
 
'declare default element namespace "urn:example/customer";
  /doc/customer[order/@year>2000]
'
);
GO

-- Create a secondary PATH index
CREATE XML INDEX PathIdxXMLdoc ON XMLdoc(doc)
USING XML INDEX PrimXIdxXMLdoc FOR PATH
;
GO

-- Run query again (look at estimated query plan again)
SELECT doc
FROM
XMLdoc
WHERE 1 = doc.exist
(
 
'declare default element namespace "urn:example/customer";
  /doc/customer[order/@year>2000]
'
);
GO

-- Now show an even simpler plan by rewriting the query to simplify the plan
-- Look at estimated query plan

SELECT doc
FROM
XMLdoc
WHERE 1 = doc.exist
(
 
'declare default element namespace "urn:example/customer";
 
/doc/customer/order/@year[.>2000]
'
);
GO

posted on Tuesday, April 26, 2005 8:17 PM by mrys


# Material for my MSDN WebCast &amp;quot;Making the Most of XQuery with SQL Server 2005&amp;quot; @ Tuesday, April 26, 2005 11:31 PM

You will be able to get the WebCast recording and copies of the slides&nbsp;from the MSDN website (registration...

mrys




Powered by Dot Net Junkies, by Telligent Systems