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


The query has been canceled because the estimated cost of this query


The query has been canceled because the estimated cost of this query

Author
Message
Anuj Rathi
Anuj Rathi
SSC-Enthusiastic
SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)

Group: General Forum Members
Points: 107 Visits: 176
Hi Experts,
I am getting below error while executing the stored procedure.

The query has been canceled because the estimated cost of this query (3258) exceeds the configured threshold of 2500. Contact the system administrator.

I am importing the XML into the table. Actually, I am uploading CSV contacts in my application & then push the XML to sql server. Here, I extract the contacts using xpath query, & save into a table. In my local machine, this code works fine while I upload this code on production server, it raises the above error. below is the sample code which I am using:

INSERT INTO @TempTable(FullName, FirstName, LastName, Email, DateOfBirth, CountryCode)
SELECT FullName = T.Item.query('fullname').value('.', 'VARCHAR(256)'),
FirstName = T.Item.query('firstname').value('.', 'VARCHAR(256)'),
LastName = T.Item.query('lastname').value('.', 'VARCHAR(256)'),
Email = T.Item.query('email').value('.', 'VARCHAR(256)'),
DOB = CASE WHEN T.Item.query('dateofbirth').value('.', 'VARCHAR(10)') = '' THEN NULL
ELSE CONVERT(DATE, T.Item.query('dateofbirth').value('.', 'VARCHAR(10)'), 103)
END,
CC = T.Item.query('country').value('.', 'CHAR(2)')
FROM @xmlData.nodes('contacts/contact') AS T(Item);

above code works fine & takes only few milliseconds on my local system but throws an error on production server.
Anuj Rathi
Anuj Rathi
SSC-Enthusiastic
SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)

Group: General Forum Members
Points: 107 Visits: 176
I have found a solution. I also want to share with you guys.

http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/31f80c1f-6285-4966-b7ed-9d0f93816f52
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39136 Visits: 38519
Anuj Rathi (1/26/2013)
I have found a solution. I also want to share with you guys.

http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/31f80c1f-6285-4966-b7ed-9d0f93816f52


Making it a hot link:

http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/31f80c1f-6285-4966-b7ed-9d0f93816f52

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85471 Visits: 41081
Anuj Rathi (1/26/2013)
I have found a solution. I also want to share with you guys.

http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/31f80c1f-6285-4966-b7ed-9d0f93816f52


Whoa! Thank you very much for posting the solution and it's real nice that a person on that thread recommended creating some XML indexes, but in the name of Codd and all that is holy in the world of databases, let's back the database truck up a couple of miles.

Ok... let's ask a question here. How many people think that storing a CSV column of data in a database is a good idea? ;-) Even if you could index it, would it be a good idea?

I certainly hope no one thinks so. So why do people allow what turns out to be some highly denormalized data with HUGE and (many times) unnecessary delimiters that will screw up their online indexing because of the blob content to be stored in their databases???

Forget about the XML indexes. Normalize the data and store it in the database correctly!

{EDIT} Yeah, yeah... I know 2012 overcomes the blob-content problem with rebuilding indexes online. What's been the excuse since 2000 came out? That doesn't change the fact that XML is one of the most horribly bloated, pipe clogging, disk hogging, memory eating, denormalized methods of communication ever devised (Heh... man, it was hard to keep THAT clean:-D). :-P

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Anuj Rathi
Anuj Rathi
SSC-Enthusiastic
SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)

Group: General Forum Members
Points: 107 Visits: 176
Hi Jeff,
You are right. This is not good to save CSV in database. I also don't save xml data into database.

I think Sathya (who proposed that solution) was thinking that I save my CSV in database & this is the query to fetch records.
But this is not the case. Actually, I have to import contacts CSV in my web application. Here I convert this CSV contacts into XML & pass this XML to database as XML data type.
Here @xmlData is the variable which receives input data in my stored procedure. then I extract data with the help of XQuery & save into my table.
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