SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The SQL Server 2005 XML Temptress


The SQL Server 2005 XML Temptress

Author
Message
Mike Arney
Mike Arney
SSC-Enthusiastic
SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)SSC-Enthusiastic (137 reputation)

Group: General Forum Members
Points: 137 Visits: 109

Did you experiment with SQL 2005's xml indexes? I wonder if they could be used in the sample last name query of the view...


Simon Munro-308389
Simon Munro-308389
Grasshopper
Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)

Group: General Forum Members
Points: 24 Visits: 34

Ken,
I accept your criticism of the use of boolean discriminator attributes. There are other mechanisms (such as an IsInClass function using bitwise operators) that would allow for the implementation of richer classification mechanisms – but I thought that it would distract from the intention of the article.

The use of some other field, as opposed to an attribute within the xml fragment is redundant but is intended for some performance gain by not having to query the xml directly in order to retrieve the initial subset that you may be interested in and therefore I would avoid having classification structures contained solely within the xml itself.

Simon


Simon Munro-308389
Simon Munro-308389
Grasshopper
Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)

Group: General Forum Members
Points: 24 Visits: 34

Wanderer,
When it comes to accessing the database I am fairly anal about how developers access the database and tend to create an abstraction layer for developers that use more simple datatypes – regardless of how the data is being physically stored. I don’t like the approach of developers arbitrarily creating their own database access – for reasons that go beyond datatypes – the best way to ensure that developers do not bring your database to its knees is to be ware of how the database is being accessed – although I understand that this is not possible in all environments. I have experimented with xml schemas and find that SQL server implements them well but I haven’t had a need to put them into production – yet. Perhaps once the schemas are cast in stone it is something that I would be obliged to do. I would think that there would be a performance knock on inserts using schemas but queries and indexes may be faster – some investigations would be required on large data volumes to really understand the performance considerations.

Simon


Simon Munro-308389
Simon Munro-308389
Grasshopper
Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)

Group: General Forum Members
Points: 24 Visits: 34

Mike,
I like the idea of indexes in xml datatypes, particularly when combined with schemas. There was a comment in one of Steve’s editorial posts a few weeks ago that said something like “let databases do what they are good at – rows and columns” – this makes sense but a small feature such as indexes on xml raises the question “well what if SQL databases were good at xml too?” I don’t know much about the internals of the database engine but I imagine that if the xml indexes were handled in the same way as ‘normal’ indexes that you could get similar performance – regardless of whether your index is on a field or an xml attribute. So, if the query plan for a field looks the same as a query plan for xml, using index seeks, then surely we could argue that SQL databases are becoming good at handling not just rows and columns, but xml too?
My current implementations are tentative seductions by the xml temptress and although it appears that indexes on xml data do work, I haven’t taken the time yet to perform some real tests.

Simon


Fred AFF
Fred AFF
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 36

Very interresting article Simon, to be honest i am still in the position you had one year ago : never even think about it :-) .

Here is a quick comment on Grant's strategy regarding feeding of amount of data .

But after a time, and that does vary, testing is required, the number of calls gets nasty. So instead, we pump the data into XML and then use OPENXML (with all it's memory bloat) to shred the data into a table with a single insert statement and it performs better than the multiple calls from the middle tier or client.

The assumption is correct : row by row management is much slower than an enssemblist aproach . That's exactly why bcp tool exists: bulk copy data from flat file to database. If you can pass parameter through a sp, i guess you can easily store them on a flat file, load it in database and apply your stored proc on an enssemblist way. I bet you'll come back to what dataserver is best for.

Fred


Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)

Group: General Forum Members
Points: 54498 Visits: 32769
We probably could use BCP and realize some performance improvements, definately. However, we're finding the performance is more than adequate, we've got it in Production as well as having tested it to a fair thee well, and the amount of code on both sides of the equation, the app server & the database, is a lot less than implementing a bcp solution would be. It really is working. Don't get me wrong. I don't see it as a magic bullet. It merely fills our needs well and could fill others needs under similar circumstances. As usual with databases, it depends.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search