Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » SQL




 Page 1 of 1 [ 6 posts ] 



Author Message
 Post subject: Query
 Post Posted: Sat Nov 21, 2009 2:08 pm 
Offline

Joined: Sat Feb 21, 2009 11:41 am
Posts: 45
I haev 2 select a query which was takin sum more time 2 retrieve da
data wid the where the condition.
coudl neone suggest the best alternative query that realy
improves da performance also.


Code:
select * from table
where Id between 1 AND 2 and and date1 between '01/01/1989' and getdate()



Thanks 4 ur help in advance !!


Top 
 Post subject: Re: Query
 Post Posted: Sat Nov 21, 2009 2:08 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Are either [ID] or [date1] columns indexed? Does da tab have ne
primary key?


Top 
 Post subject: Re: Query
 Post Posted: Sat Nov 21, 2009 2:09 pm 
Offline

Joined: Sat Feb 21, 2009 11:41 am
Posts: 45
Id was the primary key nd date1 is indexed..


Top 
 Post subject: Re: Query
 Post Posted: Sat Nov 21, 2009 2:09 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
So you r gettin two rows returnd? How long does it take
? Are u runnin dis statement in a Query Window r via an app ?


Top 
 Post subject: Re: Query
 Post Posted: Sat Nov 21, 2009 2:09 pm 
Offline

Joined: Sat Feb 21, 2009 11:41 am
Posts: 45
Presently i m runnin in query window it wsa taking around sum
45 seconds 2 get da results


Top 
 Post subject: Re: Query
 Post Posted: Sat Nov 21, 2009 2:10 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
could you post the plan output:

Code:
set showplan_text on
go
select * from table
where Id between 1 AND 2 and and date1 between '01/01/1989' and getdate()
go
set showplan_text off



Also, while the statement is running - when showplan_text is OFF, in another window run "sp_who2 active" to see if there is anything blocking (blkby column)

Finally, I don't think it should matter but try:
Code:
select <explicit column list>
from table
where id >=1
and id <= 2
and date1 >= '01/01/1989'
and date1 <= getdate()


Does this table have large blob column(s) ie: text, ntext, varchar(max), image, etc. ?


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 6 posts ] 




Board index » Server Side Development » SQL


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron