Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
Delete
27 posts, Page 2 of 3
««
1
2
3
»»
Delete
Rate Topic
Display Mode
Topic Options
Author
Message
John Rowan
John Rowan
Posted Wednesday, June 11, 2008 2:23 PM
Hall of Fame
Group: General Forum Members
Last Login: Tuesday, January 29, 2013 10:54 AM
Points: 3,837,
Visits: 3,821
Also, your WHERE clause of PO.PODescription LIKE '%00000%' will normally produce a table scan. It's a bit hard to say for sure though as you have not posted an execution plan or your index structure as requested by the other posters.
John Rowan
======================================================
======================================================
Forum Etiquette: How to post data/code on a forum to get the best help
- by Jeff Moden
Post #515499
Matt Miller (#4)
Matt Miller (#4)
Posted Wednesday, June 11, 2008 2:50 PM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 4:20 PM
Points: 6,998,
Visits: 13,947
John Rowan (6/11/2008)
Also, your WHERE clause of PO.PODescription LIKE '%00000%' will normally produce a table scan. It's a bit hard to say for sure though as you have not posted an execution plan or your index structure as requested by the other posters.
Agreed, although I can't think of how that wouldn't cause a table scan, thanks to the leading %. That kind of forces a table scan (or a clustered index scan), since there's no decent way to use an index to seek those out.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #515517
Lynn Pettis
Lynn Pettis
Posted Wednesday, June 11, 2008 3:08 PM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 21,602,
Visits: 27,431
Matt Miller (6/11/2008)
John Rowan (6/11/2008)
Also, your WHERE clause of PO.PODescription LIKE '%00000%' will normally produce a table scan. It's a bit hard to say for sure though as you have not posted an execution plan or your index structure as requested by the other posters.
Agreed, although I can't think of how that wouldn't cause a table scan, thanks to the leading %. That kind of forces a table scan (or a clustered index scan), since there's no decent way to use an index to seek those out.
I also agree, but we have to go with what the OP provided. There is one thing, and unfortunately I don't have time to try and find it, I thought I had read in "Inside Microsoft SQL Server 2005 T-SQL Querying" that SQL Server 2005 had some improvements in its statitistics that improved query performance with leading wildcard characters in the LIKE clause. When I have some free time (what ever that is) I will see if I can find it again.
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)
Post #515533
John Rowan
John Rowan
Posted Wednesday, June 11, 2008 3:10 PM
Hall of Fame
Group: General Forum Members
Last Login: Tuesday, January 29, 2013 10:54 AM
Points: 3,837,
Visits: 3,821
Yes, please do. I'd be interested in reading that if you find it.
Thanks Lynn!
John Rowan
======================================================
======================================================
Forum Etiquette: How to post data/code on a forum to get the best help
- by Jeff Moden
Post #515535
Sangeeta Satish Jadhav-362431
Sangeeta Satish Jadhav-362431
Posted Thursday, June 12, 2008 5:05 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, June 10, 2009 12:58 AM
Points: 10,
Visits: 18
Try this...
DELETE FROM tbItem l (nolock)
Where exists(Select p.POID From tbProductionOrder p (nolock) where l.POID = p.POID AND PODescription LIKE '%00000%')
Post #515782
Jeff Moden
Jeff Moden
Posted Thursday, June 12, 2008 8:37 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 9:57 PM
Points: 32,906,
Visits: 26,790
Not sure the use of a correlated subquery (a form of hidden RBAR) will speed anything up here... Maybe...
The real fact of the matter is the OP says it used to work just fine... and doesn't now... what could be the problem? Parallelism?
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
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."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #515975
Lynn Pettis
Lynn Pettis
Posted Thursday, June 12, 2008 10:13 AM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 21,602,
Visits: 27,431
Jeff Moden (6/12/2008)
Not sure the use of a correlated subquery (a form of hidden RBAR) will speed anything up here... Maybe...
The real fact of the matter is the OP says it used to work just fine... and doesn't now... what could be the problem? Parallelism?
True enough Jeff. Looking back at the original post (and paraphrasing), the system is hanging and the factory floor can't work. The issue could be blocking. Pretty sure that the NOLOCK hint is ignored on the delete, and if the DELETE is going to delete 11,000,000 rows, I wouldn't be surprised if SQL puts a table lock on the table.
If it was working before but isn't now, the two things that come to my mind now would be data and disk fragmentation. The OP should check these out.
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)
Post #516078
steveb.
steveb.
Posted Thursday, June 12, 2008 10:28 AM
SSCrazy
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 7:42 AM
Points: 2,802,
Visits: 7,103
Could it be a case of your disks filling up with the transaction log?
have you checked for free space?
Post #516086
Jeff Moden
Jeff Moden
Posted Thursday, June 12, 2008 2:14 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 9:57 PM
Points: 32,906,
Visits: 26,790
Lynn Pettis (6/12/2008)
Jeff Moden (6/12/2008)
Not sure the use of a correlated subquery (a form of hidden RBAR) will speed anything up here... Maybe...
The real fact of the matter is the OP says it used to work just fine... and doesn't now... what could be the problem? Parallelism?
True enough Jeff. Looking back at the original post (and paraphrasing), the system is hanging and the factory floor can't work. The issue could be blocking. Pretty sure that the NOLOCK hint is ignored on the delete, and if the DELETE is going to delete 11,000,000 rows, I wouldn't be surprised if SQL puts a table lock on the table.
If it was working before but isn't now, the two things that come to my mind now would be data and disk fragmentation. The OP should check these out.
Correct, WITH (NOLOCK) only affects SELECTs.
I just can believe the delete of 11 million rows didn't get caught blocking before. Somethings not quite right here. I think Lynn is on the right track... I've seen it where the undocumented ability to DELETE alias has bitten folks before. Gotta follow the rules and delete from a table name, instead.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
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."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #516250
noeld
noeld
Posted Thursday, June 12, 2008 2:30 PM
SSCertifiable
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:39 PM
Points: 6,260,
Visits: 1,977
Jeff Moden (6/12/2008)
Lynn Pettis (6/12/2008)
Jeff Moden (6/12/2008)
Not sure the use of a correlated subquery (a form of hidden RBAR) will speed anything up here... Maybe...
The real fact of the matter is the OP says it used to work just fine... and doesn't now... what could be the problem? Parallelism?
True enough Jeff. Looking back at the original post (and paraphrasing), the system is hanging and the factory floor can't work. The issue could be blocking. Pretty sure that the NOLOCK hint is ignored on the delete, and if the DELETE is going to delete 11,000,000 rows, I wouldn't be surprised if SQL puts a table lock on the table.
If it was working before but isn't now, the two things that come to my mind now would be data and disk fragmentation. The OP should check these out.
Correct, WITH (NOLOCK) only affects SELECTs.
I just can believe the delete of 11 million rows didn't get caught blocking before. Somethings not quite right here. I think Lynn is on the right track... I've seen it where the undocumented ability to DELETE alias has bitten folks before. Gotta follow the rules and delete from a table name, instead.
Sometimes there is no tracking in the amount of rows on tables and a sudden increase can be a "surprise" ;)
* Noel
Post #516262
« Prev Topic
|
Next Topic »
27 posts, Page 2 of 3
««
1
2
3
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.