SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Advice Plz...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Sonu619
Posting Yak Master

195 Posts

Posted - 11/10/2012 :  03:10:14  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/10/2012 :  07:31:39  Show Profile  Reply with Quote
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

195 Posts

Posted - 11/10/2012 :  23:44:28  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/11/2012 :  07:43:59  Show Profile  Reply with Quote
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

Canada
594 Posts

Posted - 11/11/2012 :  15:33:18  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000