外表关联的对外视图查询数据量对耗时影响大

为了更快的定位您的问题,请提供以下信息,谢谢
【详述】
【背景】SQL查询union all视图发现当hive_catalog.qr_view.t_report_all无数据explain查询SQL耗时100ms, 而有数据时耗时1s


-- 视图:

qr_view.t_report_all

-- 视图创建SQL类似:
-- 内表
select * from default_catalog.qr_view.t_report_all where par_hour >= '2025-05-01 00:00:00'

union all
-- hive外表
select * from hive_catalog.qr_view.t_report_all where par_hour < '2025-05-01 00:00:00';

-- hive_catalog 为hive表, 两个表par_hour均为分区键

无数据的执行计划:

Planner:
     - -- Parser[1] 2ms
     - -- Total[1] 62ms
     -     -- Analyzer[1] 14ms
     -         -- Lock[1] 0
     -         -- AnalyzeDatabase[26] 0
     -         -- AnalyzeTemporaryTable[26] 0
     -         -- AnalyzeTable[26] 0
     -     -- MVTextRewrite[2] 0
     -     -- Transformer[1] 7ms
     -     -- Optimizer[1] 16ms
     -         -- MVPreprocess[1] 0
     -         -- RuleBaseOptimize[1] 12ms
     -         -- CostBaseOptimize[1] 2ms
     -         -- PhysicalRewrite[1] 1ms
     -         -- PlanValidate[1] 0
     -             -- InputDependenciesChecker[1] 0
     -             -- TypeChecker[1] 0
     -             -- CTEUniqueChecker[1] 0
     -             -- ColumnReuseChecker[1] 0
     -     -- ExecPlanBuild[1] 2ms
     - -- Pending[1] 0
     - -- Prepare[1] 0
     - -- Deploy[1] 77ms
     -     -- DeployLockInternalTime[1] 77ms
     -         -- DeploySerializeConcurrencyTime[5] 17ms
     -         -- DeployStageByStageTime[15] 2ms
     -         -- DeployWaitTime[15] 48ms
     -             -- DeployAsyncSendTime[202] 1ms
     - DeployDataSize: 2065890
    Reason:

存在数据的执行计划:

Planner:
     - -- Parser[1] 2ms
     - -- Total[1] 1s221ms
     -     -- Analyzer[1] 13ms
     -         -- Lock[1] 0
     -         -- AnalyzeDatabase[26] 0
     -         -- AnalyzeTemporaryTable[26] 0
     -         -- AnalyzeTable[26] 0
     -     -- MVTextRewrite[2] 0
     -     -- Transformer[1] 7ms
     -     -- Optimizer[1] 593ms
     -         -- MVPreprocess[1] 0
     -         -- RuleBaseOptimize[1] 589ms
     -         -- CostBaseOptimize[1] 2ms
     -         -- PhysicalRewrite[1] 0
     -         -- PlanValidate[1] 0
     -             -- InputDependenciesChecker[1] 0
     -             -- TypeChecker[1] 0
     -             -- CTEUniqueChecker[1] 0
     -             -- ColumnReuseChecker[1] 0
     -     -- ExecPlanBuild[1] 2ms
     - -- Pending[1] 0
     - -- Prepare[1] 0
     - -- Deploy[1] 83ms
     -     -- DeployLockInternalTime[1] 83ms
     -         -- DeploySerializeConcurrencyTime[5] 21ms
     -         -- DeployStageByStageTime[15] 2ms
     -         -- DeployWaitTime[15] 51ms
     -             -- DeployAsyncSendTime[202] 1ms
     - DeployDataSize: 2065890
    Reason:

可以看到RuleBase耗时严重,同时SQL具体执行计划的explain查看均只命中基表数据
【业务影响】
【是否存算分离】否
【StarRocks版本】3.3.16
【集群规模】例如:3fe(1 follower+2observer)+5be(fe与be混部)
【机器信息】CPU虚拟核/内存/网卡,例如:48C/64G/万兆
【联系方式】为了在解决问题过程中能及时联系到您获取一些日志信息,请补充下您的联系方式,例如:社区群4-小李或者邮箱,谢谢
【附件】

  • fe.log/beINFO/相应截图
  • 慢查询:
    • Profile信息
    • 并行度:show variables like ‘%parallel_fragment_exec_instance_num%’;
    • pipeline是否开启:show variables like ‘%pipeline%’;
    • be节点cpu和内存使用率截图
      ±------------------------------------±------+
      | Variable_name | Value |
      ±------------------------------------±------+
      | parallel_fragment_exec_instance_num | 1 |
      ±------------------------------------±------+
      ±-------------------------------------------±------+
      | Variable_name | Value |
      ±-------------------------------------------±------+
      | enable_pipeline_engine | true |
      | enable_pipeline_level_multi_partitioned_rf | false |
      | max_pipeline_dop | 64 |
      | pipeline_dop | 0 |
      | pipeline_profile_level | 1 |
      | pipeline_sink_dop | 0 |
      ±-------------------------------------------±------+
  • 查询报错:
  • be crash
    • be.out
  • 外表查询报错
    • be.out和fe.warn.log