[ 
https://issues.apache.org/jira/browse/HIVE-24663?focusedWorklogId=604357&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-604357
 ]

ASF GitHub Bot logged work on HIVE-24663:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Jun/21 07:51
            Start Date: 01/Jun/21 07:51
    Worklog Time Spent: 10m 
      Work Description: deniskuzZ commented on a change in pull request #2266:
URL: https://github.com/apache/hive/pull/2266#discussion_r642865407



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -5394,6 +5410,476 @@ public void countOpenTxns() throws MetaException {
     }
   }
 
+  private void cleanOldStatsFromPartColStatTable(Map<PartitionInfo, 
ColumnStatistics> statsPartInfoMap,
+                                                 Connection dbConn) throws 
SQLException {
+    PreparedStatement preparedStatement = null;
+    int numRows = 0;
+    int maxNumRows = MetastoreConf.getIntVar(conf, 
ConfVars.DIRECT_SQL_MAX_ELEMENTS_VALUES_CLAUSE);
+
+    // Index is present on DB_NAME,TABLE_NAME,COLUMN_NAME,PARTITION_NAME. use 
that.
+    // TODO : Need to add catalog name to the index
+    String delete = "DELETE FROM \"PART_COL_STATS\" where \"DB_NAME\" = ? AND "
+            + "\"TABLE_NAME\" = ? AND \"COLUMN_NAME\" = ? AND 
\"PARTITION_NAME\" = ? "
+            + "AND \"PART_ID\" = ?";
+
+    try {
+      preparedStatement = sqlGenerator.prepareStmtWithParameters(dbConn, 
delete, null);
+      for (Map.Entry entry : statsPartInfoMap.entrySet()) {
+        ColumnStatistics colStats = (ColumnStatistics) entry.getValue();
+        PartitionInfo partitionInfo = (PartitionInfo) entry.getKey();
+        for (ColumnStatisticsObj statisticsObj : colStats.getStatsObj()) {
+          preparedStatement.setString(1, colStats.getStatsDesc().getDbName());
+          preparedStatement.setString(2, 
colStats.getStatsDesc().getTableName());
+          preparedStatement.setString(3, statisticsObj.getColName());
+          preparedStatement.setString(4, 
colStats.getStatsDesc().getPartName());
+          preparedStatement.setLong(5, partitionInfo.partitionId);
+          numRows++;
+          preparedStatement.addBatch();
+          if (numRows == maxNumRows) {
+            preparedStatement.executeBatch();
+            numRows = 0;
+            LOG.debug("Executed delete " + delete + " for numRows " + numRows);
+          }
+        }
+      }
+
+      if (numRows != 0) {

Review comment:
       it's more for readablility




-- 
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: 604357)
    Time Spent: 8h 20m  (was: 8h 10m)

> Reduce overhead of partition column stats updation.
> ---------------------------------------------------
>
>                 Key: HIVE-24663
>                 URL: https://issues.apache.org/jira/browse/HIVE-24663
>             Project: Hive
>          Issue Type: Sub-task
>            Reporter: Rajesh Balamohan
>            Assignee: mahesh kumar behera
>            Priority: Major
>              Labels: performance, pull-request-available
>          Time Spent: 8h 20m
>  Remaining Estimate: 0h
>
> When large number of partitions (>20K) are processed, ColStatsProcessor runs 
> into DB issues. 
> {{ db.setPartitionColumnStatistics(request);}} gets stuck for hours together 
> and in some cases postgres stops processing. 
> It would be good to introduce small batches for stats gathering in 
> ColStatsProcessor instead of bulk update.
> Ref: 
> https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java#L181
> https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java#L199



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to