Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

Mistery never ending query Expand / Collapse
Author
Message
Posted Tuesday, June 04, 2013 6:56 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:24 AM
Points: 12,744, Visits: 31,069


show the real query, and you can generate an estimated execution plan without running the query at all. just highlight the query and click the button for estimated execution plan.




Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1459732
Posted Tuesday, June 04, 2013 7:09 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 4:29 AM
Points: 129, Visits: 510
I transformed the data so what I showed is yhe actual query
And the estimated plan never is calculated. It just keeps running for hours until I stop it
Post #1459745
Posted Tuesday, June 04, 2013 7:10 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 4:29 AM
Points: 129, Visits: 510
ChrisM@Work (6/4/2013)
ricardo_chicas (6/4/2013)
All
I can't even generate the exec plan. It never ends, and none is using that table since it is a copy of the original
And none is blocking that spod either
This is only happenning to me with that specific query


Not even an estimated plan?


Yes. Not even the estimate, and only happenning on that table.
Post #1459748
Posted Tuesday, June 04, 2013 7:21 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:24 AM
Points: 12,744, Visits: 31,069
wow that's unusual, can you check for corruption? that might explain everything:

dbcc checktable ('YourTableName') WITH ALL_ERRORMSGS

DBCC CHECKDB (<Database Name>) WITH NO_INFOMSGS, ALL_ERRORMSGS




Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1459754
Posted Tuesday, June 04, 2013 7:21 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 11:18 AM
Points: 22,492, Visits: 30,188
While this query is running in one SSMS tab, switch to another tab and run sp_who2. Is the spid running your stuck query blocked?



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 #1459755
Posted Tuesday, June 04, 2013 7:54 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:33 AM
Points: 6,754, Visits: 12,854
ricardo_chicas (6/3/2013)
if I remove field 2 from the equation it will work just fine

Any ideas?



An actual plan from the whole original query with "field 2" commented out as you describe will help immensely.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1459782
Posted Tuesday, June 04, 2013 8:09 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 4:29 AM
Points: 129, Visits: 510
I just solved the issue by adding a new index ( not necessary since I was using the clustered one)
the query started working, then I removed the new index and the issue is gone
The table was new and not corrupted, so this was indeed some kind of bug
Post #1459793
Posted Tuesday, June 04, 2013 8:22 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:33 AM
Points: 6,754, Visits: 12,854
ricardo_chicas (6/4/2013)
I just solved the issue by adding a new index ( not necessary since I was using the clustered one)
the query started working, then I removed the new index and the issue is gone
The table was new and not corrupted, so this was indeed some kind of bug


It's more likely to be stale statistics than a bug. Can you post the actual plan now please?


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1459798
Posted Tuesday, June 04, 2013 8:34 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 4:29 AM
Points: 129, Visits: 510
I am 100% sure it is a bug, you can even replicate it on your side if you also have a 2012 RTM server
just create a table like this

CREATE TABLE [dbo].[temptable2](
[Field1] [varchar](23) NOT NULL,
[field2] [varchar](20) NULL,
[field3] [varchar](50) NULL,
[field4] [datetime] NULL,
[field5] [varchar](255) NULL
) ON [PRIMARY]

Create clustered index idx1 on temptable2(field1)

load it with at least 100k rows

then do this:

select field3,count(1)
from temptable2
group by field3


it will never ever ends, now that is only happening on 2012, I just test it in a 2008 R2 sp2 server and it worked fine
Post #1459802
Posted Tuesday, June 04, 2013 8:55 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:24 AM
Points: 12,744, Visits: 31,069
nope, not a valid test/way to reproduce the issue.

here's your exact code, but loaded with random data.
on my machine, with all four versions of SQL Server I have installed (2005/2008/2008R2/2012), it returned results in about 9 seconds.

CREATE TABLE [dbo].[temptable2](
[Field1] [varchar](23) NOT NULL,
[field2] [varchar](20) NULL,
[field3] [varchar](50) NULL,
[field4] [datetime] NULL,
[field5] [varchar](255) NULL
) ON [PRIMARY]

Create clustered index idx1 on temptable2(field1)

INSERT INTO temptable2
SELECT TOP 200000
LEFT(CONVERT(varchar(50),NEWID()),23), --23 chars
LEFT(CONVERT(varchar(50),NEWID()),20),--20 chars
LEFT(CONVERT(varchar(50),NEWID()),50),--50 chars
CAST(RAND(CHECKSUM(NEWID()))*3653.0+36524.0 AS DATETIME), --datetime
LEFT(CONVERT(varchar(255),NEWID()),255) --255 chars
FROM sys.columns T1 cross apply sys.columns T2

select field3,count(1)
from temptable2
group by field3



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1459810
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse