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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 [RESOLVED] Query timing out (may not be a query pr

Author  Topic 

jar21

51 Posts

Posted - 2008-09-04 : 15:57:30
Hi this query is used to display who has not been paid, but when its run it simply times out. This query was given to me by a 3rd party company and I know extremely little about Queries, I just want to check with people I believe may know more :-)

SELECT distinct(OrderAssignment.Assignment_ID), EmployeeMaster.First_Name, EmployeeMaster.Last_Name, OrderAssignment.Start_DateTime, OrderAssignment.End_Actual_Date
FROM EmployeeMaster, OrderAssignment, OrderMaster
WHERE OrderAssignment.Employee_ID = EmployeeMaster.Employee_ID AND OrderMaster.Order_ID = OrderAssignment.Order_ID
AND (OrderAssignment.End_Actual_Date Between {ts '2008-01-01 00:00:00'} And {ts '2008-09-30 00:00:00'}) OR (OrderAssignment.End_Actual_Date Is Null)
and orderassignment.assignment_id not in (
select AssignmentKey from AIM_TimecardHIST where WeekEnding Between {ts '2008-01-01 00:00:00'} And {ts '2008-09-30 00:00:00'})

when it runs it does nothing at all but time out after a certain amount of time.


Enjoy Life This Is Not A Rehearsal.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-04 : 16:03:25
What indexes do you have on the 4 tables involved in this query?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jar21

51 Posts

Posted - 2008-09-04 : 16:16:39
I'm extremely lacking knowledge in this area.....(HUGE NOOB) by indexes I'm not even sure what you mean. (pretend you are talking to someone who knows absolutely nothing about SQL's

Enjoy Life This Is Not A Rehearsal.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-04 : 19:21:39
Then get the knowledge about it.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-04 : 19:31:59
quote:
Originally posted by sodeep

Then get the knowledge about it.



We don't need this kind of attitude here. Do not post rude comments like this or your account will be locked.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jar21

51 Posts

Posted - 2008-09-05 : 11:23:00
I believe there are 37 indexes (I checked by going into the sql server and expanding the databases then expanding indexes, I'm not sure if thats what you meant. while it may have been rude, hes right albeit I'm 21, and havent touched a database up until about 3 or 4 weeks ago.

p.s. we edited the query and it works now. I'm not entirely sure what is different but there is one line that was added (from what I can see) "ORDER BY 1"


Actually as a side note, is there a view or query I can run to view.. say.. the last 15 databases or 500 fields?




Enjoy Life This Is Not A Rehearsal.
Go to Top of Page
   

- Advertisement -