Hi All, Query1 with better filter/selection perfor...
# troubleshooting
r
Hi All, Query1 with better filter/selection performs worse than Query2 with out
l.hs_crn = 'HS-11913514'
• user_tbl has
11490324 rows
• leads_wide_tbl has
11490334 rows
and invertedIndexColumns is
hs_crn
Query 1 (“timeUsedMs”:
4276
):
Copy code
select 
  u.user_name,
  l.lead_name,
  l.hs_crn
from user_tbl u
  join leads_wide_tbl l on l.user_id = u.user_id
where l.last_updated_on >= 1727634600000
  and l.city = 'BANGALORE'
  and l.hs_crn = 'HS-11913514'
limit 100
Query 2(timeUsedMs”:
897
):
Copy code
select 
  u.user_name,
  l.lead_name,
  l.hs_crn
from user_tbl u
  join leads_wide_tbl l on l.user_id = u.user_id
where l.last_updated_on >= 1727634600000
  and l.city = 'BANGALORE'
limit 100
Plan shows the filter getting applied -
Copy code
Execution Plan
LogicalSort(offset=[0], fetch=[100])
  PinotLogicalSortExchange(distribution=[hash], collation=[[]], isSortOnSender=[false], isSortOnReceiver=[false])
    LogicalSort(fetch=[100])
      LogicalProject(user_name=[$1], lead_name=[$3], hs_crn=[$2])
        LogicalJoin(condition=[=($4, $0)], joinType=[inner])
          PinotLogicalExchange(distribution=[hash[0]])
            LogicalProject(user_id=[$9], user_name=[$10])
              LogicalTableScan(table=[[default, nb_user_tbl]])
          PinotLogicalExchange(distribution=[hash[2]])
            LogicalProject(hs_crn=[$21], lead_name=[$33], user_id=[$52])
              LogicalFilter(condition=[AND(>=($32, 1727634600000), =($10, _UTF-8'BANGALORE'), =($21, _UTF-8'HS-11913514'))])
                LogicalTableScan(table=[[default, hs_leads_wide_tbl]])
b
Hi . If possible, please try using
SET explainPlanVerbose=true;
as that should show if index is actually used in leaf (bottom-most) stage. You can see what took the most time by inspecting stage stats, see https://docs.pinot.apache.org/users/user-guide-query/multi-stage-query/understanding-stage-stats .
One reason Query 2 is faster is that it needs to scan less data to reach the limit of 100 rows (since there's no order by ).