SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


this query is taking time for execution how to trouble shoot


this query is taking time for execution how to trouble shoot

Author
Message
naga.rohitkumar
naga.rohitkumar
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1520 Visits: 1378
HI every one application team informed that this query is taking more time than normal so from my end what should i do?

select xfrq.bay_user_id,xfrq.fr_acid,cusr.c_m_phone_no,cusr.c_email_id,xfrq.txn_amt,xfrq.end_date
from xfrq,cusr where xfrq.bay_user_id = cusr.bay_user_id
and xfrq.r_mod_id = 'FTONLDISP'and
datepart(dd,xfrq.r_mod_time)=13
and
datepart(mm,xfrq.r_mod_time)=04
and
datepart(yyyy,xfrq.r_mod_time)=2013
and
xfrq.res_code=000

Thanks
Naga.Rohitkumar
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)

Group: General Forum Members
Points: 207142 Visits: 41961
The biggest problem with the current query is that it's not possible for an INDEX SEEK (and subsequent range scan) to occur on the r_mod_time column because of the formulas you have wrapped around the column. This is how to fix that as well as impart what most people would be some "best practices". Of course, you have to have the correct indexes, as well.

 SELECT x.bay_user_id
, x.fr_acid
, c.c_m_phone_no
, c.c_email_id
, x.txn_amt,
, x.end_date
FROM dbo.cusr c
JOIN dbo.xfrq x ON x.bay_user_id = c.bay_user_id
WHERE x.r_mod_id = 'FTONLDISP'
AND x.res_code = 0
AND x.r_mod_time >= '20130413' AND x.r_mod_time < '20130414'
;



--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search