perf(selfop): stabilize profile candidate join order

This commit is contained in:
2026-10-13 02:00:14 +08:00
parent bf693fab6b
commit 2c8c26490a
2 changed files with 26 additions and 1 deletions
@@ -56,7 +56,8 @@ public interface OutboundAggregateMapper {
MAX(CASE WHEN outbound_rank=1 THEN observation_run_id END) evidence_run_id,
MAX(CASE WHEN seen_rank=1 THEN observation_run_id END) last_seen_run_id
FROM (
SELECT o.customer_code,i.sku_code,i.product_name,i.quantity_unit,o.outbound_at_utc,
SELECT /*+ JOIN_ORDER(o,i,s,r,t) INDEX(s idx_selfop_stage_fact_observation) */
o.customer_code,i.sku_code,i.product_name,i.quantity_unit,o.outbound_at_utc,
s.observed_at_utc,s.run_id observation_run_id,
ROW_NUMBER() OVER (PARTITION BY o.customer_code,i.sku_code ORDER BY o.outbound_at_utc,o.id) outbound_rank,
ROW_NUMBER() OVER (PARTITION BY o.customer_code,i.sku_code ORDER BY s.observed_at_utc DESC,s.id DESC) seen_rank