[ https://issues.apache.org/jira/browse/HIVE-22238?focusedWorklogId=338689&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-338689 ]
ASF GitHub Bot logged work on HIVE-22238: ----------------------------------------- Author: ASF GitHub Bot Created on: 05/Nov/19 12:28 Start Date: 05/Nov/19 12:28 Worklog Time Spent: 10m Work Description: kgyrtkirk commented on pull request #831: HIVE-22238 pkfk URL: https://github.com/apache/hive/pull/831#discussion_r342535997 ########## File path: ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java ########## @@ -1961,6 +1961,7 @@ public static void updateStats(Statistics stats, long newNumRows, newDV = (long) Math.ceil(ratio * oldDV); } cs.setCountDistint(newDV); + cs.setFilterColumn(); Review comment: I'm not sure - I don't think so...actually because we may end up filtering rows in a join as well - I think it's more accurate to fave this. I was trying to come up with some query which might be relevant...but they doesn't really made sense...query requirements: * we need to have a join condition on the FK - where we would not set it as a filterColumn * we need to have a 2. join condition on the same FK I think queries like the following make not much sense; and the filter on FK could be movedf to the PK side which has lesser number of rows anyway...so its kinda useless... ``` select 1 from torpedos t, ships s, something ???, where true -- join#1 condition(x-fk) ; it is required to use t.ship_id and t.ship_id = ??? -- the pk-fk condition and t.ship_id = s.id ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 338689) Time Spent: 40m (was: 0.5h) > PK/FK selectivity estimation underscales estimations > ---------------------------------------------------- > > Key: HIVE-22238 > URL: https://issues.apache.org/jira/browse/HIVE-22238 > Project: Hive > Issue Type: Bug > Components: Statistics > Reporter: Zoltan Haindrich > Assignee: Zoltan Haindrich > Priority: Major > Labels: pull-request-available > Attachments: HIVE-22238.01.patch, HIVE-22238.02.patch, > HIVE-22238.03.patch, HIVE-22238.04.patch, HIVE-22238.05.patch, > HIVE-22238.05.patch, HIVE-22238.05.patch, HIVE-22238.05.patch, > HIVE-22238.05.patch > > Time Spent: 40m > Remaining Estimate: 0h > > at [this > point|https://github.com/apache/hive/blob/5098d155a1e6a164253f5fa98755273bc34085df/ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java#L2182] > the parent operators rownum is scaled according to pkfkselectivity > however [pkfkselectivity is > computed|https://github.com/apache/hive/blob/5098d155a1e6a164253f5fa98755273bc34085df/ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java#L2157] > on a whole subtree. > Scaling it by that amount will count in estimation already used when > parentstats was calculated...so depending on the number of upstream joins - > this may lead to severe underestimations > what happened was: > * optimization was able to push the filter to the other side of the join > * as a result the incoming data was already filtered > * scaling down by the PK selectiviy - was actually already there...but a new > "scaling" happened -- This message was sent by Atlassian Jira (v8.3.4#803005)