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 2000 Forums
 SQL Server Development (2000)
 Timeout Expired

Author  Topic 

Samadhi69
Starting Member

20 Posts

Posted - 2009-04-13 : 12:09:04
ID_Account is the primary key, but has at least one ID_House. I'm trying to get the largest (most recent) ID_Account for each ID_House so I run the following:

Select ID_House, max(ID_Account) AS ID_Current
From Account
Group by ID_House


This gives the message (after about 1 min) "[Microsoft][ODBC SQL Server Driver]Timeout expired"

This is a rather large table (12million plus records) but the DB is on this machine, so I'm at a loss for why it would give me a timeout.

Any ideas would be appreciated.

If con is the opposite of pro, what's the opposite of progress?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-13 : 12:33:37
Do you have an index on ID_House?

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Samadhi69
Starting Member

20 Posts

Posted - 2009-04-13 : 13:07:33
I figured that would do it, but was avoiding it for various reasons. I'll just have to enforce best practices on this db sooner than I was planning (I inherited it so to speak).
Thanks

If con is the opposite of pro, what's the opposite of progress?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-13 : 13:41:33
You're welcome.

You may want to add ID_Account to that index so that it is a composite index and does not need to do a lookup on the clustered index (if you have one) to get that data. I'd compare the performance of just ID_House and then also ID_House, ID_Account. If you don't buy hardly any performance or none at all with the composite index, then just go with ID_House so that you don't impact writes.

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -