为了更快的定位您的问题,请提供以下信息,谢谢
【详述】Hello,我们有子查询的场景,最外层会进行精确去重计算,想咨询下类似这种语句,如何创建物化视图,可以使物化视图覆盖率更高
【背景】无
【业务影响】
【是否存算分离】
【StarRocks版本】3.2.8
【集群规模】例如:3fe(1 follower+2observer)+5be(fe与be混部)
查询的SQL为:
select date(t1.data_date) as time_grain_DAY_data_date_ab2f32026c0d4b768ec03d38dbc1a487,
t1.product_name as product_name_9fb7889a8eb0456aa7f7cdd4dad7e41c,
t1.source_result as source_result_96df155c890c4f6ab30690993ee609ce,
t1.source_result_2 as source_result_2_dd6d590a81434441911f6215f5976527,
t1.risk_level as risk_level_95ecc774bdf04a45b1e3611f0d0d9953,
count(distinct
(if(((t1.is_apply_local_filter in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_a277e82c15b74b99b1f457edbfa4c963,
count(distinct
(if(((t1.is_pass_local_filter in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_14166f94db3e414b85216c9fa613dead,
count(distinct
(if(((t1.is_apply_third_filter in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_3a0e1e85cd9940268ebf8921aa9f6c75,
count(distinct
(if(((t1.is_pass_third_filter in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_e6bac021dfe84bb5aec024172a30d225,
count(distinct
(if(((t1.is_apply_distribute in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_0acf4762de58413993a3272cfdfbaa2e,
count(distinct
(if(((t1.is_pass_distribute in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_12eeccb5dfb742ff8f7337c5544f3e6c,
count(distinct
(if(((t1.apply_id is not null)), t1.user_guid, null))) as count_if_distinct_user_guid_6ab6122930264bbebc14d3f0082be060,
count(distinct
(if(((t1.is_credit_succ in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_af1135ec0be04477bd62c4e48ebcc4a8,
sum(if(((t1.loan_rank in (1))), t1.credit_amount, null)) as sum_if_credit_amount_1af19972b9ca434598a6a54ec90a1d1a,
count(distinct
(if(((t1.is_apply_loan in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_2843802c74d148a9b92a86af7b26e1e2,
count(distinct
(if(((t1.is_loan_succ in (1))), t1.user_guid, null))) as count_if_distinct_user_guid_033323fdbe6a4f50b1e0285dbe17d215,
sum(if(((t1.is_loan_succ in (1))), t1.amount, null)) as sum_if_amount_23c2cefa53be4859bbbf6d7930938fc9
from (select data_date,
user_id,
user_guid,
user_new_id,
flow_batch_id,
pre_filter_platform,
pre_filter_platform_desc,
source_id,
product_id,
product_name,
pre_filter_user_source,
is_apply_second,
is_pass_second,
is_apply_local_filter,
is_pass_local_filter,
is_apply_ocr,
is_pass_ocr,
is_apply_third_filter,
is_pass_third_filter,
is_apply_distribute,
is_pass_distribute,
is_credit_succ,
credit_user_source,
credit_platform,
credit_source_id,
credit_source_name,
credit_platform_desc,
credit_amount,
available_amount,
credit_expiry_time,
credit_create_time,
credit_result_time,
order_id,
capital_id,
capital_name,
loan_platform,
loan_platform_desc,
apply_amount,
apply_period,
apply_period_unit,
amount,
period,
period_unit,
apply_id,
lent_time,
payoff_time,
loan_create_time,
loan_state,
loan_code,
loan_msg,
is_need_buy_package,
risk_loan_result_time,
risk_loan_state,
risk_create_time,
is_pass_hello_risk_order,
user_type,
funder_facility_state,
funder_facility_state_desc,
funder_facility_apply_date,
funder_facility_date,
guarantor_facility_state,
guarantor_facility_state_desc,
guarantor_facility_apply_date,
guarantor_facility_date,
funder_loan_state,
funder_loan_state_desc,
funder_loan_apply_time,
funder_loan_time,
guarantor_loan_state,
guarantor_loan_state_desc,
guarantor_loan_apply_date,
guarantor_loan_date,
– repaytment_state,
– due_date,
– current_period_if_overdue,
– current_overdues,
– overdue_days,
– if_prepay,
loan_user_source,
user_type_srb,
user_type_srb_risk,
biz_mode,
biz_mode_name,
is_loan_succ,
api_loan_time,
api_loan_date,
is_fst_loan,
fst_loan_order_id,
fst_loan_product_id,
fst_loan_platform,
before_amount,
after_amount,
change_amount,
fst_loan_is_api,
fst_pass_loan_time,
extra_params,
interest_unit_display,
loan_interest_display,
is_t0_loan,
third_id,
is_apply_credict,
is_apply_loan,
loan_rank,
source_result,
source_result_2,
risk_level,
apply_sort,
pt
from tableName
where pt <= ‘20240801’) t1
where ((date_format(str_to_date(t1.data_date, ‘%Y-%m-%d %H:%i:%s’), ‘%Y-%m-%d %H:%i:%s’) >=
concat(cast(‘2024-07-26’ as varchar), cast(’ 19:39:50’ as varchar)) and
date_format(str_to_date(t1.data_date, ‘%Y-%m-%d %H:%i:%s’), ‘%Y-%m-%d %H:%i:%s’) <=
concat(cast(‘2024-08-01’ as varchar), cast(’ 19:39:50’ as varchar)) or
‘2024-07-19 00:00:00’ <= date_format(str_to_date(t1.data_date, ‘%Y-%m-%d’), ‘%Y-%m-%d %H:%i:%s’) and
‘2024-07-23 23:59:59’ >= date_format(str_to_date(t1.data_date, ‘%Y-%m-%d’), ‘%Y-%m-%d %H:%i:%s’)) or
t1.product_name in (‘ttt’))
group by date(t1.data_date), t1.product_name, t1.source_result, t1.source_result_2, t1.risk_level,t1.product_name
limit 20000
类似上述的SQL,我应该怎么建立物化视图加速我的查询,并使该物化视图覆盖率更全一些,user_guid为字符串类型,