Re: how to optimise query for 10+ millions records
Posted by:
Azhar Rahi
Date: February 20, 2012 02:21AM
No dear, I did not add any new field in the query. It was the same query which I sent you before. Now I tested it by excluding a field Dur. The current query is
SELECT destination.DestinationId , COUNT(*) TotaCalls , DestinationName -- , SUM(DUR)/60 TotalMinutes
-- ,SUM(IF(Dur > 0,1,0)) TSC -- TSC = Total successful calls
-- ,ROUND((SUM(IF(Dur > 0,1,0)) / COUNT(*)) * 100, 2) ASR -- ASR = Average Success Ratio
-- ,IF(SUM(Dur) > 0, ROUND((SUM(Dur)/60)/SUM(IF(Dur > 0,1,0)), 2),0) ACD
FROM axecdr
FORCE INDEX (indx_DateTimeDestination) -- (indx_StartDateTime, indx_DateTimeDestination, indx_StartDateDestination, indx_AxeCdrStats)
LEFT JOIN destination ON axecdr.DestinationId = destination.DestinationID
WHERE start_date BETWEEN '2012-01-27' AND '2012-02-03'
AND Start_Time BETWEEN '00:00:00' AND '23:59:59' -- AND axecdr.DestinationID = @p_DestinationID
AND IF(@p_CarrierType = 0 AND TRIM(@p_Carriers) <> '', axecdr.IN_ROUTE IN (SELECT `VALUE` FROM IN_ROUTE), axecdr.ID)
AND IF(@p_CarrierType = 1 AND TRIM(@p_Carriers) <> '', axecdr.OUT_ROUTE IN (SELECT `VALUE` FROM OUT_ROUTE), axecdr.ID)
AND IFNULL(destination.DestinationName,'Unknown') LIKE @l_Destination
GROUP BY IFNULL(destination.DestinationName,'Unknown')
When I include the field Dur, it gets slow and takes upto 45-50 seconds but when I exclude it, it takes 11-12 seconds.
Subject
Views
Written By
Posted
2866
February 09, 2012 03:30AM
1699
February 09, 2012 05:31AM
1363
February 09, 2012 05:38AM
1262
February 09, 2012 05:58PM
1249
February 11, 2012 11:26PM
1499
February 12, 2012 10:12PM
1352
February 13, 2012 02:18PM
1563
February 14, 2012 02:33AM
1349
February 14, 2012 07:24AM
1372
February 15, 2012 07:30AM
1826
February 16, 2012 03:54AM
1264
February 17, 2012 01:20AM
1223
February 17, 2012 03:57PM
1504
February 17, 2012 05:12PM
1308
February 18, 2012 07:18AM
1370
February 21, 2012 03:25AM
1359
February 24, 2012 10:45AM
Re: how to optimise query for 10+ millions records
1304
February 20, 2012 02:21AM