THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

Page Free Space

See also my SQL Server technical articles on SQLperformance.com

Hello Operator, My Switch Is Bored

Published Tuesday, June 11, 2013 10:00 PM by Paul White

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

mjswart said:

"Belated attempt at brevity"

I'm going to use that.

June 11, 2013 8:52 AM
 

Paul White said:

Michael,

You didn't see the copyright notice?

;c)

Paul

June 11, 2013 9:01 AM
 

Rob Farley said:

Eighteen posts for T-SQL Tuesday #43 this month , discussing Plan Operators. I put them together and

June 13, 2013 7:00 AM
 

Mikael Eriksson said:

A switch operator. I know, it's XML but anyway. http://stackoverflow.com/a/23910600/569436

May 29, 2014 12:34 PM
 

Paul White said:

Mikael,

That is an awesome example. I have no clue what it's doing there, but it's great to see it :)

May 29, 2014 12:56 PM
 

Mikael Eriksson said:

The switch is there if you combine constructed XML with and xpath in a .query() like in this simple thing:

declare @X xml = '<X>1</X>';

select @X.query('<Y>{X}</Y>');

At a query cost of 1370 it gives me a nice little parallel plan :).

The operators to the right of the concatenation operator returns a value that is used by the switch to figure out if the XML is constructed or queried. The constructed XML is returned as is (switch directs to the constant scan) and queried part goes to the XML Reader.

I looks like the constant scan to the right of the switch is just there to provide one row and it is the switch itself that defines that input parameters to the switch is returned directly in the <DefinedValues> part of the switch operator.

May 30, 2014 8:41 AM

Leave a Comment

(required) 
(required) 
Submit
Privacy Statement