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


How to debug query


How to debug query

Author
Message
JimS-Indy
JimS-Indy
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1065 Visits: 444
I apologize to all for my poor forum etiquette. I thought my problem was T-SQL related. I was wrong, and my query's poor performance seems to have a DB issue.

...I put CPAS into single-user mode to lock out users. I've put it back in multi-user mode and rerun the backup. It's running now.
...Even though CPAS could not back up, the error file does seem to show problems with indexes. How do I rebuild all the indexes?
...The backup job just finished normally, and the "long-running query" ran in 4 seconds. Back to normal.

...My backup job does reorganize the indexes, so maybe that fixed it. I dunno.

I really appreciate everyone's time and attention. Again, I apologize for the "dual-threaded" post. It was not meant to be that way.

Jim
JimS-Indy
JimS-Indy
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1065 Visits: 444
I apologize for my "dual-threaded" post. What I thought was a T-SQL error appears to have been corrupted indices or some other odd corruption.

...I ran the backup plan once again (with the db back in multi-user mode...) and it worked. I'm not sure why. In any case, the offending query now runs in 4 seconds (has to go through a couple million rows...) and the users' report pops up even faster. So, problem solved.

I want to thank all of you for helping me. I admit to some panic, but I do have lots of backups, so it wouldn't have been too bad, and I learned something.

If anyone wants to review my backup plan (capture.png) and criticize it, I'd be grateful. If not, thanks anyway!

Again, thank you all for the help. Oops....didn't realize I'd posted twice. Sorry

Jim
GilaMonster
GilaMonster
SSC Guru
SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)

Group: General Forum Members
Points: 225697 Visits: 46321
JimS-Indy (5/9/2013)
...Even though CPAS could not back up, the error file does seem to show problems with indexes. How do I rebuild all the indexes?


What error shows problems with the indexes?

If you mean
Source: Reorganize Index
Description: The Execute method on the task returned error code 0x80131501 (An exception occurred while executing a Transact-SQL statement or batch.). The Execute method must succeed, and indicate the result using an "out" parameter.

that would be the same cause as the backups failing, specifically that the DB was in single user mode and there was already an open connection to the database, hence the rebuild failed because it could not connect to the database.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


JimS-Indy
JimS-Indy
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1065 Visits: 444
Gail, I don't know what the problem was. It seems to have gone away when I ran the backup successfully. As I said, that step includes a "reorganize index" step, so maybe that fixed the indexes. The error file had:

Error: 2013-05-09 14:50:40.63
Code: 0xC0024104
Source: Reorganize Index
Description: The Execute method on the task returned error code 0x80131501 (An exception occurred while executing a Transact-SQL statement or batch.). The Execute method must succeed, and indicate the result using an "out" parameter.
End Error

Which I (not knowing what I'm looking at...) interpreted as a separate error.

Jim
GilaMonster
GilaMonster
SSC Guru
SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)SSC Guru (225K reputation)

Group: General Forum Members
Points: 225697 Visits: 46321
That would have been caused by exactly the same thing that caused the backups to fail, the database being in single-user mode and an existing connection to the database, hence the reorganise would not have been able to connect and would have failed.
Once you switched out of single-user mode, the backups and reorganise could run successfully.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


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