Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Timeout issue

Author  Topic 

mrtweaver
Yak Posting Veteran

67 Posts

Posted - 2009-03-27 : 09:58:41
I have a server running MS Server 2005. On this server I have MS SQL 2005. It has 6 gigs of memory. While observing the CPU usage, under task manager, under normal circumstance the usage runs around 10% to 14%. Which is in my opinion really good. However I am having trouble with some of the queries I have written. Attached here is one of them. The problem is when I run this query, which by the way is a view and it pulls its data from an actual table, the CPU usuage pegs out at 100%, sometimes it drops back down and then provides the data, other times it stays peged and gives a server timeout. Can someone please look at this and tell me is it my query or is there something wrong with my server.
================================================================
SELECT TOP (100) PERCENT machine, jobtask, operator, assist1, assist2, assist3, AVG(eff) AS eff, AVG(cpm) AS cpm, MAX(accum) AS accum, MAX(prod_date)
AS t_stamp, ISNULL(SUM(CASE WHEN lunch = 0 AND paperwrk = 0 THEN (runtime) END), 0) AS prodtime, shift, serial,
ISNULL(SUM(CASE WHEN lunch = 1 THEN (runtime) END), 0) AS lunch, ISNULL(SUM(CASE WHEN paperwrk = 1 THEN (runtime) END), 0) AS paperwork,
ISNULL(SUM(CASE WHEN stpbar = 0 AND lunch = 0 AND paperwrk = 0 THEN (runtime) END), 0) AS idle,
ISNULL(SUM(CASE WHEN stpbar = 1 THEN (runtime) END), 0) AS runtime, CASE WHEN machine >= 1 AND
machine <= 59 THEN 'Inserting' WHEN machine >= 60 AND machine <= 79 THEN 'Addressing and Ink Jetting' WHEN machine >= 80 AND
machine <= 99 THEN 'Bindery' ELSE 'other' END AS type
FROM dbo.Prodtrack AS i
WHERE (operator <> 0) AND (jobtask <> 0) AND (accum <> 0)
GROUP BY machine, jobtask, operator, assist1, assist2, assist3, shift, serial
ORDER BY t_stamp, shift
==================================================================

Thanks for looking and have a great day.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-27 : 10:33:01
Seems nothing wrong with this query
dbo.csp_JobLog_OK 'cmart001'



SELECT machine,
jobtask,
operator,
assist1,
assist2,
assist3,
AVG(eff) AS eff,
AVG(cpm) AS cpm,
MAX(accum) AS accum,
MAX(prod_date) AS t_stamp,
SUM(CASE WHEN lunch = 0 AND paperwrk = 0 THEN runtime ELSE 0 END) AS prodtime,
shift,
serial,
SUM(CASE WHEN lunch = 1 THEN runtime ELSE 0 END) AS lunch,
SUM(CASE WHEN paperwrk = 1 THEN runtime ELSE 0 END) AS paperwork,
SUM(CASE WHEN stpbar = 0 AND lunch = 0 AND paperwrk = 0 THEN runtime ELSE 0 END) AS idle,
SUM(CASE WHEN stpbar = 1 THEN runtime ELSE 0 END) AS runtime,
CASE
WHEN machine >= 1 AND machine <= 59 THEN 'Inserting'
WHEN machine >= 60 AND machine <= 79 THEN 'Addressing and Ink Jetting'
WHEN machine >= 80 AND machine <= 99 THEN 'Bindery'
ELSE 'other'
END AS type
FROM dbo.Prodtrack
WHERE operator <> 0
AND jobtask <> 0
AND accum <> 0
GROUP BY machine,
jobtask,
operator,
assist1,
assist2,
assist3,
shift,
serial
How do your execution plan look like?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -