Hi all,
I am using mysql 5 on solaris 8.
I am executing a query which is taking 34sec.
Query
select Dim_Hospital
.cityOfHospital
as c0
, DO_Closure
.parentId
as c1
, sum(Fact_ClaimTr
.finalBillAmt
) as m0
, count(Fact_ClaimTr
.pioId
) as m1
from Dim_Hospital
as Dim_Hospital
, Fact_ClaimTr
as Fact_ClaimTr
, DO_Closure
as DO_Closure
where Fact_ClaimTr
.hospitalId
= Dim_Hospital
.id
and Fact_ClaimTr
.pioId
= DO_Closure
.insuOfficeId
and DO_Closure
.parentId
= ‘800001169443885743’ group by Dim_Hospital
.cityOfHospital
, DO_Closure
.parentId
;
explain
*************************** 1. row *************************** id: 1 select_type: SIMPLE table: Dim_Hospital type: ALLpossible_keys: PRIMARY key: NULL key_len: NULL ref: NULL rows: 33 Extra: Using temporary; Using filesort*************************** 2. row *************************** id: 1 select_type: SIMPLE table: Fact_ClaimTr type: refpossible_keys: hos_Id,pio_Id key: hos_Id key_len: 9 ref: claimanalytics.Dim_Hospital.id rows: 5769 Extra: Using where*************************** 3. row *************************** id: 1 select_type: SIMPLE table: DO_Closure type: refpossible_keys: PRIMARY key: PRIMARY key_len: 16 ref: claimanalytics.Fact_ClaimTr.pioId,const rows: 1 Extra: Using index
Table :No Of Rows
DO_Closure : 206
Fact_ClaimTr : 190387
Dim_Hospital : 33
I have indexes on all columns in join and group by clause
How can I reduce this time?
Thanks for any suggestion you can provide.
Regards
Susheel