Sql Taking More CPU time (merged) [message #483598] |
Tue, 23 November 2010 06:47  |
saiphani723
Messages: 38 Registered: July 2006 Location: Hyderabad
|
Member |
|
|
Hi all,
I have one query in my production which is taking more CPU time. when that statement executing the CUP is taking more than 90%
I am attaching the sql query and indexes on the table.
Can anyone tell me how to solve this.
|
|
|
|
Re: Sql Taking More CPU time (merged) [message #483658 is a reply to message #483598] |
Wed, 24 November 2010 00:33   |
michael_bialik
Messages: 621 Registered: July 2006
|
Senior Member |
|
|
Can you use 2 different SQL statements ?
Select Nvl(Sum(DeCode(TransCode,'59',NetPremium,(-1)*NetPremium)),0) NetPremium
From Central_Repository
Where CompanyCode = PCompanyCode
And InsuranceType = PInsuranceType
And ProposerCode = PProposerCode
And RefNo = PReferenceNo
And TransCode In ('19','59')
And TransDate <= PToDate;
Select Nvl(Sum(DeCode(TransCode,'59',NetPremium,(-1)*NetPremium)),0) NetPremium
From Central_Repository
Where CompanyCode = PCompanyCode
And InsuranceType = PInsuranceType
And ProposerCode = PProposerCode
And TransCode In ('19','59')
And TransDate <= PToDate;
How many rows do you have?
How many distinct values for CompanyCode, InsuranceType,
ProposerCode, RefNo, TransCode and TransDate columns exist?
|
|
|
Re: Sql Taking More CPU time (merged) [message #483663 is a reply to message #483658] |
Wed, 24 November 2010 00:38   |
saiphani723
Messages: 38 Registered: July 2006 Location: Hyderabad
|
Member |
|
|
Thank you for your reply.
I will try using two statements and i will get back to you.
For company code and Insurance type there will be only one value across the table. But remaining columns there were many values.
|
|
|
|