Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
SQL 2005 - SELECT query takes long time to...
14 posts, Page 1 of 2
1
2
»»
SQL 2005 - SELECT query takes long time to retrieve
Rate Topic
Display Mode
Topic Options
Author
Message
balasach82
balasach82
Posted Tuesday, July 20, 2010 6:58 AM
Old Hand
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:55 AM
Points: 307,
Visits: 743
SQL 2005 - SELECT query takes long time to retrieve records from a table which has about 250000 records. Even a top 10 takes 4 to 5 mins. Any remedial measures?
Post #955516
SQLBalls
SQLBalls
Posted Tuesday, July 20, 2010 7:07 AM
Old Hand
Group: General Forum Members
Last Login: Today @ 1:34 PM
Points: 385,
Visits: 611
When you take a look at the execution plan what do you see?
Twitter: @SQLBalls
Blog:
http://www.SQLBalls.com
Post #955524
ChrisM@Work
ChrisM@Work
Posted Tuesday, July 20, 2010 7:19 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 8:51 AM
Points: 5,608,
Visits: 10,970
balasach82 (7/20/2010)
SQL 2005 - SELECT query takes long time to retrieve records from a table which has about 250000 records. Even a top 10 takes 4 to 5 mins. Any remedial measures?
Not without seeing the query, no. You will get some help if you post the query.
You will get better help if you post the execution plans as already suggested.
For the best help, post the table definition as well, including any indexes, triggers etc along with some sample data.
“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.”
- Gail Shaw
For fast, accurate and documented assistance in answering your questions, please read
this article
.
Understanding and using APPLY, (I)
and
(II)
Paul White
Hidden RBAR: Triangular Joins
/
The "Numbers" or "Tally" Table: What it is and how it replaces a loop
Jeff Moden
Exploring Recursive CTEs by Example
Dwain Camps
Post #955537
balasach82
balasach82
Posted Tuesday, July 20, 2010 7:38 AM
Old Hand
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:55 AM
Points: 307,
Visits: 743
select * from table_name where [time] between
'2009/6/1 6:00am' and '2009/6/30'
no indexes,triggers etc. Field [time] has datatype datetime.
Post #955555
Feeg
Feeg
Posted Tuesday, July 20, 2010 7:41 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 3:16 AM
Points: 120,
Visits: 1,636
how many columns and rows is there in this table?
if it's a small table it should not take long to display the table at all without indexes on it ...
MCITP: Database Administrator 2005
soon: MCTS DBA 2008
Post #955561
balasach82
balasach82
Posted Tuesday, July 20, 2010 7:45 AM
Old Hand
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:55 AM
Points: 307,
Visits: 743
33 columns and aboutn 250,000 rows.
Execution plan shows Table Scan as 100%. Let me know if any more info is needed
Post #955569
SQLBalls
SQLBalls
Posted Tuesday, July 20, 2010 7:49 AM
Old Hand
Group: General Forum Members
Last Login: Today @ 1:34 PM
Points: 385,
Visits: 611
Right click in your query window.
click Incl
u
de Actual Execution Plan
when you execute the query next there will be an addition info that shows the Graphical query execution plan.
you probably could benefit from a non-clustered index on your date field, or a covering index if the data types are not to large.
here is a good tutorial on query optimization.
http://www.simple-talk.com/sql/performance/execution-plan-basics/
Twitter: @SQLBalls
Blog:
http://www.SQLBalls.com
Post #955577
balasach82
balasach82
Posted Tuesday, July 20, 2010 7:55 AM
Old Hand
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:55 AM
Points: 307,
Visits: 743
I had created an index the time column.. but since the query took long time to complete, i dropped that index...
As mentioned the Exec plan shows 100% table scan
Post #955585
SQLBalls
SQLBalls
Posted Tuesday, July 20, 2010 8:01 AM
Old Hand
Group: General Forum Members
Last Login: Today @ 1:34 PM
Points: 385,
Visits: 611
does the table have a clustered index?
you cannot do a covering index as the limit is 16 columns, I would deffinitally add a clustered and re-create a non clustered on time.
Twitter: @SQLBalls
Blog:
http://www.SQLBalls.com
Post #955595
GilaMonster
GilaMonster
Posted Tuesday, July 20, 2010 8:05 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:07 PM
Points: 37,687,
Visits: 29,946
Bradley B (7/20/2010)
you cannot do a covering index as the limit is 16 columns,
The 16 column limit is only on key columns, not on include columns.
balasach, please post table definitions, index definitions and execution plan, as per
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #955601
« Prev Topic
|
Next Topic »
14 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.