Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

this query is taking time for execution how to trouble shoot Expand / Collapse
Posted Saturday, April 13, 2013 12:40 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, June 18, 2015 4:08 AM
Points: 610, Visits: 1,370

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

Post #1442012
Posted Saturday, April 13, 2013 12:57 PM



Group: General Forum Members
Last Login: Today @ 4:22 PM
Points: 38,984, Visits: 36,072
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Favorite Quotes:
"Has anyone ever told you that a query you have written runs too fast?" - Dwain Camps - 6 Mar 2014

Helpful Links:
How to post code problems
How to post performance problems
Post #1442049
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse