Hi Team - I have 9 dimension tables and 1 fact tab...
# troubleshooting
a
Hi Team - I have 9 dimension tables and 1 fact table. Is it recommended to create denormalized dataset based on all the fact and dimension table and then load it to pinot for faster querying or I can still go ahead and load all the dimension tables and fact table in pinot and then join those tables through pinot query. Which would be the best recommended way? Any help would be appreciated. Thanks in advance!
m
It depends on your requirements. Pre joining will make Pinot very fast, but you have cost of pre joining. You can join in Pinot also but if you want to run expensive joins then latency may be higher What kind of joins you need to do? If lookup only then it should be fine to do in Pinot
a
Not lookup, but data explosion @Mayank.
m
How large the left and right tables being joined (post filter)?
Depending on the query, join latency can vary. So you need to decide between join latency you can take vs prejoining cost you can take
a
We are doing inner join between fact and the dimensions. I loaded 1.5 million records in fact and few dimension have data in 1000's and few dimensions have data in 10^5's
m
I think that should be ok for joins
a
Okay, but the query still failing with:
Weird error
m
what is the query and query plan?
a
Copy code
EXPLAIN PLAN FOR
SELECT 
fact.scenario,
fact.period,
fact.process_type,
fact.source_type,
fact.channel_id,
rev.parent_id as rev,
fact.account_id,
fact.product_id,
fact.company_id,
fact.location_id,
project.parent_id as project,
sum(fact.usd_amount) as usd_amount,
sum(fact.constant_amount) as constant_amount
FROM fact_data fact
INNER JOIN ref_project project ON fact.project_id = project.child_id
INNER JOIN ref_rev rev ON fact.rev_id = rev.child_id
INNER JOIN ref_account acct ON fact.account_id = acct.child_id
GROUP BY 
fact.scenario,
fact.period,
fact.process_type,
fact.source_type,
fact.channel_id,
rev.parent_id,
fact.account_id,
fact.product_id,
fact.company_id,
fact.location_id,
project.parent_id;
Execution Plan
LogicalProject(scenario=[$7], period=[$4], process_type=[$5], source_type=[$8], channel_id=[$1], parent_id0=[$10], account_id=[$0], product_id=[$6], company_id=[$2], location_id=[$3], parent_id=[$9], usd_amount=[$11], constant_amount=[$12])
  PinotLogicalAggregate(group=[{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}], agg#0=[$SUM0($11)], agg#1=[$SUM0($12)])
    PinotLogicalExchange(distribution=[hash[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
      PinotLogicalAggregate(group=[{0, 1, 2, 4, 5, 6, 7, 8, 9, 11, 12}], agg#0=[$SUM0($10)], agg#1=[$SUM0($3)])
        LogicalJoin(condition=[=($0, $13)], joinType=[inner])
          PinotLogicalExchange(distribution=[hash[0]])
            LogicalProject(account_id=[$0], channel_id=[$1], company_id=[$2], constant_amount=[$3], location_id=[$4], period=[$5], process_type=[$6], product_id=[$7], scenario=[$9], source_type=[$10], usd_amount=[$11], parent_id=[$12], parent_id0=[$14])
              LogicalJoin(condition=[=($8, $13)], joinType=[inner])
                PinotLogicalExchange(distribution=[hash[8]])
                  LogicalProject(account_id=[$0], channel_id=[$1], company_id=[$2], constant_amount=[$3], location_id=[$4], period=[$5], process_type=[$6], product_id=[$7], rev_id=[$9], scenario=[$10], source_type=[$11], usd_amount=[$12], parent_id=[$14])
                    LogicalJoin(condition=[=($8, $13)], joinType=[inner])
                      PinotLogicalExchange(distribution=[hash[8]])
                        LogicalProject(account_id=[$3], channel_id=[$5], company_id=[$6], constant_amount=[$7], location_id=[$14], period=[$15], process_type=[$16], product_id=[$17], project_id=[$18], rev_id=[$19], scenario=[$20], source_type=[$21], usd_amount=[$22])
                          LogicalTableScan(table=[[default, fact_data]])
                      PinotLogicalExchange(distribution=[hash[0]])
                        LogicalProject(child_id=[$3], parent_id=[$6])
                          LogicalTableScan(table=[[default, ref_project]])
                PinotLogicalExchange(distribution=[hash[0]])
                  LogicalProject(child_id=[$3], parent_id=[$6])
                    LogicalTableScan(table=[[default, ref_rev]])
          PinotLogicalExchange(distribution=[hash[0]])
            LogicalProject(child_id=[$8])
              LogicalTableScan(table=[[default, ref_account]])
m
Ok, this is definitely more of a DW query than OLAP IMO.
You don't have any filters, and you are grouping by 11 columns
a
Yup, as I am doing POC trying to figure out which would work and which wouldn't. Are we saying group by is one of the issues?
m
More than that, no filters
a
Got it, but I don't group by could be the issue. When I ran group by 11 column and did some aggregation on on the metric columns and added star tree index and inverted index, it worked as expected got results within ~370 ms.
m
That group by was probably on a smaller number of rows
Did you have filters?
a
Yes, I did have a filter : WHERE fact.period = 202301
m
then you are comparing apples vs oranges
a
No I understand that, but since I had only two periods loaded in fact, thought it would go through. Do you want me to add filter in the query where I am joining fact and dimension and test it?
m
It is not what I want, it is what your use case desires. 1M x 1M join can be super expensive too, eventhough the two tables individually have just 1M rows
Just by looking at the shape of your query I am thinking it looks more of a DW query and less of an OLAP query
a
Yes more like ROLAP queries
m
I suppose a better classification would be user-facing or not.