2017-06-06 14 views
0

以下のハイブクエリは、実行に無限に時間がかかります(3日以上)。クエリの最適化が役立つかどうかは不明です。ハイブクエリ実行時間が無限に長くなる

何か提案がありがとうございます!

select count(distinct(a.custname)) from (
    (select custname, pages, variable 
    from table1 
    where date_time between "2017-01-01" and "2017-01-31" 
    and (pages in ('Summary', 'Details') 
    or variable in ('Complete', 'Receive'))) a 
    left join 
    (select custname, pages, variable 
    from table1 
    where date_time between "2017-01-01 00:00:00" and "2017-01-31 00:00:00" 
    and (pages not in ('Summary', 'Details') 
    and variable not in ('Complete', 'Receive'))) b 
    on a.custname = b.custname) 
    where b.pages is null 
+0

ヨDATE_TIMEのバリアントデータフォーマットを使用しています。列の種類は何ですか?文字列の場合、実際の形式は何ですか? –

答えて

0
select count(*) 

from (select  custname 

     from  table1 

     where  date_time between date '2017-01-01' and date '2017-01-31' 

     group by custname 

     having  count 
        (
         case 
          when pages  in ('Summary' ,'Details') 
           or variable in ('Complete','Receive') 
          then 1 
         end 
        ) > 0 

       and count 
        (
         case 
          when pages not in ('Summary' ,'Details') 
           and variable not in ('Complete' ,'Receive') 
          then 1 
         end 
        ) = 0 
     ) t 
関連する問題