Return-Path: X-Original-To: apmail-hive-dev-archive@www.apache.org Delivered-To: apmail-hive-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 79A0D11EA6 for ; Tue, 23 Sep 2014 18:40:34 +0000 (UTC) Received: (qmail 26309 invoked by uid 500); 23 Sep 2014 18:40:34 -0000 Delivered-To: apmail-hive-dev-archive@hive.apache.org Received: (qmail 26217 invoked by uid 500); 23 Sep 2014 18:40:34 -0000 Mailing-List: contact dev-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list dev@hive.apache.org Received: (qmail 26202 invoked by uid 500); 23 Sep 2014 18:40:33 -0000 Delivered-To: apmail-hadoop-hive-dev@hadoop.apache.org Received: (qmail 26199 invoked by uid 99); 23 Sep 2014 18:40:33 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Sep 2014 18:40:33 +0000 Date: Tue, 23 Sep 2014 18:40:33 +0000 (UTC) From: "Mostafa Mokhtar (JIRA)" To: hive-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HIVE-8196) Joining on partition columns with fetch column stats enabled results it very small CE which negatively affects query performance MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HIVE-8196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14145208#comment-14145208 ] Mostafa Mokhtar commented on HIVE-8196: --------------------------------------- Actual row count is 108,857,602 while the estimate is 307,063,281. > Joining on partition columns with fetch column stats enabled results it very small CE which negatively affects query performance > --------------------------------------------------------------------------------------------------------------------------------- > > Key: HIVE-8196 > URL: https://issues.apache.org/jira/browse/HIVE-8196 > Project: Hive > Issue Type: Bug > Components: Physical Optimizer > Affects Versions: 0.14.0 > Reporter: Mostafa Mokhtar > Assignee: Prasanth J > Priority: Critical > Labels: performance > Fix For: 0.14.0 > > Attachments: HIVE-8196.1.patch > > > To make the best out of dynamic partition pruning joins should be on the partitioning columns which results in dynamically pruning the partitions from the fact table based on the qualifying column keys from the dimension table, this type of joins negatively effects on cardinality estimates with fetch column stats enabled. > Currently we don't have statistics for partition columns and as a result NDV is set to row count, doing that negatively affects the estimated join selectivity from the join. > Workaround is to capture statistics for partition columns or use number of partitions incase dynamic partitioning is used. > In StatsUtils.getColStatisticsFromExpression is where count distincts gets set to row count > {code} > if (encd.getIsPartitionColOrVirtualCol()) { > // vitual columns > colType = encd.getTypeInfo().getTypeName(); > countDistincts = numRows; > oi = encd.getWritableObjectInspector(); > {code} > Query used to repro the issue : > {code} > set hive.stats.fetch.column.stats=true; > set hive.tez.dynamic.partition.pruning=true; > explain select d_date > from store_sales, date_dim > where > store_sales.ss_sold_date_sk = date_dim.d_date_sk and > date_dim.d_year = 1998; > {code} > Plan > {code} > STAGE DEPENDENCIES: > Stage-1 is a root stage > Stage-0 depends on stages: Stage-1 > STAGE PLANS: > Stage: Stage-1 > Tez > Edges: > Map 1 <- Map 2 (BROADCAST_EDGE) > DagName: mmokhtar_20140919180404_945d29f5-d041-4420-9666-1c5d64fa6540:8 > Vertices: > Map 1 > Map Operator Tree: > TableScan > alias: store_sales > filterExpr: ss_sold_date_sk is not null (type: boolean) > Statistics: Num rows: 550076554 Data size: 47370018816 Basic stats: COMPLETE Column stats: COMPLETE > Map Join Operator > condition map: > Inner Join 0 to 1 > condition expressions: > 0 {ss_sold_date_sk} > 1 {d_date_sk} {d_date} > keys: > 0 ss_sold_date_sk (type: int) > 1 d_date_sk (type: int) > outputColumnNames: _col22, _col26, _col28 > input vertices: > 1 Map 2 > Statistics: Num rows: 652 Data size: 66504 Basic stats: COMPLETE Column stats: COMPLETE > Filter Operator > predicate: (_col22 = _col26) (type: boolean) > Statistics: Num rows: 326 Data size: 33252 Basic stats: COMPLETE Column stats: COMPLETE > Select Operator > expressions: _col28 (type: string) > outputColumnNames: _col0 > Statistics: Num rows: 326 Data size: 30644 Basic stats: COMPLETE Column stats: COMPLETE > File Output Operator > compressed: false > Statistics: Num rows: 326 Data size: 30644 Basic stats: COMPLETE Column stats: COMPLETE > table: > input format: org.apache.hadoop.mapred.TextInputFormat > output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat > serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe > Execution mode: vectorized > Map 2 > Map Operator Tree: > TableScan > alias: date_dim > filterExpr: (d_date_sk is not null and (d_year = 1998)) (type: boolean) > Statistics: Num rows: 73049 Data size: 81741831 Basic stats: COMPLETE Column stats: COMPLETE > Filter Operator > predicate: (d_date_sk is not null and (d_year = 1998)) (type: boolean) > Statistics: Num rows: 652 Data size: 66504 Basic stats: COMPLETE Column stats: COMPLETE > Reduce Output Operator > key expressions: d_date_sk (type: int) > sort order: + > Map-reduce partition columns: d_date_sk (type: int) > Statistics: Num rows: 652 Data size: 66504 Basic stats: COMPLETE Column stats: COMPLETE > value expressions: d_date (type: string) > Select Operator > expressions: d_date_sk (type: int) > outputColumnNames: _col0 > Statistics: Num rows: 652 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE > Group By Operator > keys: _col0 (type: int) > mode: hash > outputColumnNames: _col0 > Statistics: Num rows: 652 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE > Dynamic Partitioning Event Operator > Target Input: store_sales > Partition key expr: ss_sold_date_sk > Statistics: Num rows: 652 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE > Target column: ss_sold_date_sk > Target Vertex: Map 1 > Stage: Stage-0 > Fetch Operator > limit: -1 > Processor Tree: > ListSink > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)