databend icon indicating copy to clipboard operation
databend copied to clipboard

sql becomes slow in cluster mode

Open FANNG1 opened this issue 3 years ago • 0 comments

query-24

select t.user_id,
      t.name2,
      sum(xiaohao)
from
 (select a.name2,
         a.user_id, --a.agent_id,
case
    when (a.campaign_type in ('x',
                              'y')
          and a.ocpc_action_type in ('xx',
                                     'xx2',
                                     'xxx',
                                     'xxxx')) then 'duan'
    when (a.campaign_type in ('a',
                              'b',
                              'c')
          and a.ocpc_action_type in ('xx',
                                     'xxx')) then 'duan'
    else 'zhi'
end leixing,
(sum(cash_charged) + sum(pure_cash_charged) + sum(credit_charged)) /1000 as xj,
sum(cost_total-direct_rebate_charged) /1000-sum(Coalesce(cost_inner, 0)) /1000 as xiaohao
  from online_table.query_table a
  where p_date >= '20220101'
    and first_industry_name= 'aaa'
    and a.crm_agent_type not in ('2',
                                 '15')

    and account_type in ('11',
                         '10')

  group by a.name2,
           a.user_id,             a.user_id,
case
    when (a.campaign_type in ('aaa',
                              '13')

          and a.ocpc_action_type in ('11',
                                     '123',
                                     '121',
                                     '1111')) then 'duan'
    when (a.campaign_type in ('17',
                              '18',
                              '20')
          and a.ocpc_action_type in ('sss',
                                     '111')) then 'duan'
    else 'zhi'
end) t
where t.leixing in ('duan')
group by t.user_id,
        t.name2

query-38

select if(p_date < '20220701', 'q2', 'q3') q,
       user_id,
       sum(cost_outer) / 1000 cost
from online_table.query_table
where p_Date >= '20220401'
and user_id in (
  1,2,3, 。。。 – 几千个id
)
  and delivery_system in ('xx',
                          'x2')
  and first_industry_name = 'x1'
  and merchant_business_type = 'x2'
group by if(p_date < '20220701', 'q2', 'q3'),
         user_id

cc @zhang2014

FANNG1 avatar Sep 21 '22 02:09 FANNG1