Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

Database table in DSV Query Improvement for fact table.

$
0
0

Hello Friends

I have table in database name as Log table where record of every call is stores.

I need to do some measurement on this table so it will be my fact table.

I'm using this named Query in my DSV.

SELECT t2.uniqueID,t3.Lead_ID,t2.phone_number,t2.call_date,t1.entry_date,t2.list_id,
t2.length_in_sec,t2.status,t2.user,CASE WHEN t2.call_date = t3.call_date THEN 1 ELSE 0 END as "RedCalls",
CASE WHEN length_in_sec/60 < 1 Then "ShortCalls"
                         when length_in_sec/60 > 1 and length_in_sec/60 < 5 Then "MediumCalls"
                         when length_in_sec/60 > 5 Then "LongCalls" End as CallTimesCategory ,
                        case when status='DNC' Then 1 end as DoNotCall,
                        case when length_in_sec/60 < 1 Then 1 end as ShortCalls ,
                        case when length_in_sec/60 > 1 and length_in_sec/60 < 5 Then 1 end as MediumCalls ,
                        case when length_in_sec/60 > 5 Then 1 end as LongCalls,
                        Case when status='TPVP' then 1 end as TPV_Pending

FROM asterisk.vicidial_log t2
Inner join asterisk.vicidial_list t1 on t1.lead_ID = t2.lead_ID
LEFT JOIN
(  select lead_ID,MAX(call_date) as call_date
             from asterisk.vicidial_log
             group by lead_ID
)t3 ON t3.lead_ID = t1.lead_ID
AND t3.call_date >= DATE_ADD(t1.entry_date, INTERVAL 22 DAY)
where year(t2.call_date)>=2012

But problem is ;

Data increase in this day by day basis and it is takes long time as it also contains sub queries and all.

Is it i'm doing this in right way  or should i split this query in two or we can improve this using another method.

Kindly share your suggestions.

Regards

BI_Group



Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>