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 2008 Forums
 Transact-SQL (2008)
 Advice Plz...

Author  Topic 

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-11-10 : 03:10:14
Hi quick question
I have simple very simple query

SELECT * FROM TABLE1

TABLE1 has 587640 Rows. Its taking
5 Minutes to execute this query. I couldn't figure it out Y. My question is it normal to take 5m to execute this kinda query? if not then what should i do?

Thanks for help in advance...

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-11-10 : 07:31:39
The type of query - select * from Table1 - is asking SQL Server to give you everything in a table. Which means a table scan. There isn't much you can do to optimize the query. The time taken may be the time required to read off from the disk, network delays to get the data to your computer, etc.

Experts recommend that you do not do this type of "catch all" queries; More than likely, that many rows cannot be processed at the receiving end - so you may need only a subset; so limit it to what you need using where clauses. Also, instead of using SELECT *, list the columns that you need (and only the columns you need), as in SELECT col1, col7, col18 etc.
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-11-10 : 23:44:28
Thanks for your advise. That was just a Simple select * Statement and i notice query is taking so long. For sure if i don't need all columns i shouldn't use *. I am just wandering should i go extra mile to find out why it is taking so long.....
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-11-11 : 07:43:59
As I had indicated in my original reply, it is taking so long because of the limitations of your hardware and network. You can add more memory, get a faster processor and disks, get faster network gear etc. to speed it up.
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2012-11-11 : 15:33:18
Rdp or hop onto the server directly. Then try it. The time it takes will give you insight as to if Network or your computer is an issue.
Go to Top of Page
   

- Advertisement -