You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2017/05/10 22:49:39 UTC

[1/7] incubator-trafodion git commit: [TRAFODION-2420] RMS enhancements

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master ef4a29405 -> f28cc0894


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/regress/core/FILTERRTS
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/FILTERRTS b/core/sql/regress/core/FILTERRTS
index 8ed5b77..a26b263 100755
--- a/core/sql/regress/core/FILTERRTS
+++ b/core/sql/regress/core/FILTERRTS
@@ -6,13 +6,13 @@ if [ "$fil" = "" ]; then
   exit 1
 fi
 sed  "
-/SE_IOs  SE_IO_Bytes/{N
-s/[A-Z0-9 ,-]*\.[A-Z0-9]*\.TSTAT/#CAT.#SCH.TSTAT pertableStats/
-}
-/6       EX_HASH_GRBY/{N
-s/6       EX_HASH_GRBY[ ]*[A-Z0-9 ,-]*\n/hash_grby_stats/
+/6        EX_HASH_GRBY/{N
+s/6        EX_HASH_GRBY[ ]*[A-Z0-9 ,._-]*\n/hash_grby_stats/
 }
-s/hash_grby_stats[0-9 ,]*/@hash_grby_stats@/
+s/6 EX_HASH_GRBY [A-Z0-9 ,._-]*/@hash_grby_stats@/
+s/hash_grby_stats[0-9 ,.]*/@hash_grby_stats@/
+s/[A-Z0-9 ,-]*\.[A-Z0-9]*\.TSTATI/#CAT.#SCH.TSTATI pertableStats/
+s/[A-Z0-9 ,-]*\.[A-Z0-9]*\.TSTAT/#CAT.#SCH.TSTAT pertableStats/
 s/QID[ ]*MXID[A-Z0-9_]*/QID @QID@/
 s/QID[ ]*'MXID[A-Z0-9_]*'/QID '@QID@'/
 s/Qid[ ]*MXID[A-Z0-9_]*/Qid @QID@/
@@ -96,12 +96,12 @@ s/EX_SEND_BOTTOM[ ]*[0-9, |]*/EX_SEND_BOTTOM @exSendBottomCounters@/
 s/5    .    6    7    3    2    EX_HASH_GRBY             2[ ]*[0-9, -|A-Z]*/5    .    6    7    3    2    EX_HASH_GRBY             2 @exHashGrbyCounters@/
 s/.    .    1    2    1    3    EX_TRAF_KEY_SELECT       2[ ]*[0-9, |]*/.    .    1    2    1    3    EX_TRAF_KEY_SELECT       2 @exTrafKeySelectCounters@/
 
-/[A-Z0-9]*\.[A-Z0-9]*\.TSTAT[ ]*/{N
-s/[A-Z0-9]*\.[A-Z0-9]*\.TSTAT[ ]*\n[0-9 ,]*/#CAT.#SCH.TSTAT pertableStats/
-}
 /[A-Z0-9]*\.[A-Z0-9]*\.TSTATI[ ]*/{N
 s/[A-Z0-9]*\.[A-Z0-9]*\.TSTATI[ ]*\n[0-9 ,]*/#CAT.#SCH.TSTATI pertableStats/
 }
+/[A-Z0-9]*\.[A-Z0-9]*\.TSTAT[ ]*/{N
+s/[A-Z0-9]*\.[A-Z0-9]*\.TSTAT[ ]*\n[0-9 ,]*/#CAT.#SCH.TSTAT pertableStats/
+}
 /TSTAT(TSTAT)[ ]*/{N
 s/TSTAT(TSTAT)[ ]*\n[0-9 ]*\n[0-9 ,]*/TSTAT(TSTAT) @pertableStats@/
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/Qsort.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sort/Qsort.cpp b/core/sql/sort/Qsort.cpp
index 73aa8a5..5198394 100644
--- a/core/sql/sort/Qsort.cpp
+++ b/core/sql/sort/Qsort.cpp
@@ -59,8 +59,8 @@
 Qsort::Qsort(ULng32 runsize, ULng32 sortmaxmem, ULng32  recsize,
              NABoolean doNotallocRec, ULng32  keysize, 
              SortScratchSpace* scratch, NABoolean iterSort,
-             CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, SortUtil* sortutil):
-             SortAlgo(runsize, recsize, doNotallocRec, keysize, scratch, explainNodeId),
+             CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, ExBMOStats *bmoStats, SortUtil* sortutil):
+             SortAlgo(runsize, recsize, doNotallocRec, keysize, scratch, explainNodeId, bmoStats),
              currentRun_(1), loopIndex_(0), heap_(heap), sortError_(sorterror),
              sortMaxMem_(sortmaxmem), sortUtil_(sortutil)
 {
@@ -92,11 +92,6 @@ Qsort::Qsort(ULng32 runsize, ULng32 sortmaxmem, ULng32  recsize,
   //-----------------------------------------------------------------------
   loopIndex_ = 0;
   recNum_ = 0;
-  ExOperStats *stat = sortUtil_->config()->getCallingTcb()->getStatsEntry();
-  if (stat)
-    bmoStats_ = stat->castToExBMOStats();
-  else
-    bmoStats_ = NULL;
   if (bmoStats_)
     bmoStats_->updateBMOHeapUsage((NAHeap *)heap_);
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/Qsort.h
----------------------------------------------------------------------
diff --git a/core/sql/sort/Qsort.h b/core/sql/sort/Qsort.h
index af1c7e6..bac03af 100644
--- a/core/sql/sort/Qsort.h
+++ b/core/sql/sort/Qsort.h
@@ -122,7 +122,7 @@ public:
 
   Qsort(ULng32 recmax,ULng32 sortmaxmem, ULng32 recsize, NABoolean doNotallocRec, 
         ULng32 keysize, SortScratchSpace* scratch,NABoolean iterQuickSort,
-        CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, SortUtil* sortutil);
+        CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, ExBMOStats *bmoStats, SortUtil* sortutil);
   ~Qsort(void);
 
   Lng32 sortSend(void* rec, ULng32 len, void* tupp);
@@ -162,7 +162,6 @@ private:
   CollHeap* heap_;
   SortUtil* sortUtil_;
   ULng32 initialRunSize_;
-  ExBMOStats *bmoStats_;
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/SortAlgo.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sort/SortAlgo.cpp b/core/sql/sort/SortAlgo.cpp
index ae60dfb..42804f2 100644
--- a/core/sql/sort/SortAlgo.cpp
+++ b/core/sql/sort/SortAlgo.cpp
@@ -30,7 +30,7 @@
 //-----------------------------------------------------------------------
 SortAlgo::SortAlgo(ULng32 runsize, ULng32 recsize, 
                    NABoolean doNotAllocRec, ULng32 keysize, 
-                   SortScratchSpace* scratch, Lng32 explainNodeId)
+                   SortScratchSpace* scratch, Lng32 explainNodeId, ExBMOStats *bmoStats)
 {
   sendNotDone_   = TRUE_L;
   runSize_       = runsize;
@@ -41,6 +41,7 @@ SortAlgo::SortAlgo(ULng32 runsize, ULng32 recsize,
   numCompares_   = 0L;
   internalSort_  = TRUE_L;
   explainNodeId_ = explainNodeId;
+  bmoStats_      = bmoStats;
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/SortAlgo.h
----------------------------------------------------------------------
diff --git a/core/sql/sort/SortAlgo.h b/core/sql/sort/SortAlgo.h
index bb32959..c3903f3 100644
--- a/core/sql/sort/SortAlgo.h
+++ b/core/sql/sort/SortAlgo.h
@@ -56,7 +56,7 @@ class SortAlgo : public NABasicObject
 
    SortAlgo(ULng32 runsize, ULng32 recsize, 
             NABoolean doNotallocRec, ULng32 keysize, 
-            SortScratchSpace* scratch, Lng32 explainNodeId);
+            SortScratchSpace* scratch, Lng32 explainNodeId, ExBMOStats *bmoStats);
    ~SortAlgo() {}; 
      
    //------------------------------------------------------------
@@ -96,6 +96,7 @@ class SortAlgo : public NABasicObject
    NABoolean internalSort_;
    NABoolean doNotallocRec_;
    Lng32 explainNodeId_;
+   ExBMOStats *bmoStats_;
 
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/SortTopN.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sort/SortTopN.cpp b/core/sql/sort/SortTopN.cpp
index 90b56d7..0ef3221 100644
--- a/core/sql/sort/SortTopN.cpp
+++ b/core/sql/sort/SortTopN.cpp
@@ -60,8 +60,8 @@
 SortTopN::SortTopN(ULng32 runsize, ULng32 sortmaxmem, ULng32  recsize,
              NABoolean doNotallocRec, ULng32  keysize, 
              SortScratchSpace* scratch, NABoolean iterSort,
-             CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, SortUtil* sortutil):
-             SortAlgo(runsize, recsize, doNotallocRec, keysize, scratch, explainNodeId),
+             CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, ExBMOStats *bmoStats, SortUtil* sortutil):
+             SortAlgo(runsize, recsize, doNotallocRec, keysize, scratch, explainNodeId, bmoStats),
              loopIndex_(0), heap_(heap), sortError_(sorterror),
              sortUtil_(sortutil)
 {
@@ -79,11 +79,6 @@ SortTopN::SortTopN(ULng32 runsize, ULng32 sortmaxmem, ULng32  recsize,
   ex_assert(topNKeys_  != NULL, "Sort: Initial topNKeys_ allocation failed");  
   
   recNum_ = 0;
-  ExOperStats *stat = sortUtil_->config()->getCallingTcb()->getStatsEntry();
-  if (stat)
-    bmoStats_ = stat->castToExBMOStats();
-  else
-    bmoStats_ = NULL;
   if (bmoStats_)
     bmoStats_->updateBMOHeapUsage((NAHeap *)heap_);
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/SortTopN.h
----------------------------------------------------------------------
diff --git a/core/sql/sort/SortTopN.h b/core/sql/sort/SortTopN.h
index cd7e4f9..6432155 100644
--- a/core/sql/sort/SortTopN.h
+++ b/core/sql/sort/SortTopN.h
@@ -49,7 +49,7 @@ public:
 
   SortTopN(ULng32 recmax,ULng32 sortmaxmem, ULng32 recsize, NABoolean doNotallocRec, 
   ULng32 keysize, SortScratchSpace* scratch,NABoolean iterQuickSort,
-  CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, SortUtil* sortutil);
+  CollHeap* heap, SortError* sorterror, Lng32 explainNodeId, ExBMOStats *bmoStats, SortUtil* sortutil);
   ~SortTopN(void);
 
   Lng32 sortSend(void* rec, ULng32 len, void* tupp);
@@ -81,7 +81,6 @@ private:
   SortError* sortError_;
   CollHeap* heap_;
   SortUtil* sortUtil_;
-  ExBMOStats *bmoStats_;
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/SortUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sort/SortUtil.cpp b/core/sql/sort/SortUtil.cpp
index 74bb2c8..2d626b3 100644
--- a/core/sql/sort/SortUtil.cpp
+++ b/core/sql/sort/SortUtil.cpp
@@ -173,6 +173,7 @@ NABoolean SortUtil::sortInitialize(SortUtilConfig& config, ULng32 topNSize)
                                   config.heapAddr_,
                                   &sortError_,
                                   explainNodeId_,
+                                  bmoStats_,
                                   this);
 
   }
@@ -189,6 +190,7 @@ NABoolean SortUtil::sortInitialize(SortUtilConfig& config, ULng32 topNSize)
                                    config.heapAddr_,
                                    &sortError_,
                                    explainNodeId_,
+                                   bmoStats_,
                                    this);
   }
   if (sortAlgo_ == NULL)
@@ -496,7 +498,8 @@ Lng32 SortUtil::sortSendEndProcessing(void)
   if (stats_.numRuns_ > (Lng32) config_->mergeOrder_)
   {
     state_ = SORT_INTERMEDIATE_MERGE;
-
+    if (bmoStats_)
+       bmoStats_->setBmoPhase(ExSortTcb::SortPhase::SORT_PHASE_END-ExSortTcb::SortPhase::SORT_MERGE_PHASE);
     if (config_->logInfoEvent())
     {
       char msg[500];
@@ -522,6 +525,7 @@ Lng32 SortUtil::sortSendEndProcessing(void)
                                                   config_->heapAddr_,
                                                   &sortError_,
                                                   explainNodeId_,
+                                                  bmoStats_,
                                                   this,
                                                   runnum, 
                                                   TRUE_L, TRUE);
@@ -579,6 +583,7 @@ Lng32 SortUtil::sortSendEndProcessing(void)
                                                   config_->heapAddr_,
                                                   &sortError_,
                                                   explainNodeId_,
+                                                  bmoStats_,
                                                   this,
                                                   runnum, 
                                                   TRUE_L,TRUE);
@@ -680,6 +685,7 @@ Lng32 SortUtil::sortSendEndProcessing(void)
                                             config_->heapAddr_,
                                             &sortError_,
                                             explainNodeId_,
+                                            bmoStats_,
                                             this,
                                             runnum, 
                                             TRUE_L,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/TourTree.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sort/TourTree.cpp b/core/sql/sort/TourTree.cpp
index 957be6d..04e4674 100644
--- a/core/sql/sort/TourTree.cpp
+++ b/core/sql/sort/TourTree.cpp
@@ -43,9 +43,11 @@
 #include <iostream>
 #include <fstream>
 #include <string.h>
+#include "ex_stdh.h"
 #include "TourTree.h"
 #include "SortUtil.h"
 #include "ex_ex.h"
+#include "ExStats.h"
 
 //------------------------------------------------------------------------
 // This file contains the all member function definitions of Tree class. 
@@ -68,8 +70,8 @@
 Tree::Tree(ULng32 numruns, ULng32 runsize, ULng32 recsize, 
            NABoolean doNotAllocRec, ULng32 keysize,
            SortScratchSpace* scratch, CollHeap *heap, SortError *sorterror, 
-           Lng32 explainNodeId, SortUtil* sortUtil, Lng32 runnum, NABoolean merge,NABoolean waited) :
-           SortAlgo(runsize, recsize, doNotAllocRec, keysize, scratch, explainNodeId),
+           Lng32 explainNodeId, ExBMOStats *bmoStats, SortUtil* sortUtil, Lng32 runnum, NABoolean merge,NABoolean waited) :
+           SortAlgo(runsize, recsize, doNotAllocRec, keysize, scratch, explainNodeId, bmoStats),
            maxRuns_(0), currentRun_(0), winnerRun_(0), sortError_(sorterror),
            heap_(heap), sortUtil_(sortUtil) 
 {
@@ -378,6 +380,8 @@ Lng32 Tree::generateInterRuns()
        {
          rSize = winner_->record()->getRecSize();
        }
+       if (bmoStats_)
+           bmoStats_->incInterimRowCount();
        retcode = winner_->outputScr(currentRun_+numRuns, rSize, scratch_,TRUE_L);
        if (retcode != 0)
        {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/sort/TourTree.h
----------------------------------------------------------------------
diff --git a/core/sql/sort/TourTree.h b/core/sql/sort/TourTree.h
index dce103f..a108c8c 100644
--- a/core/sql/sort/TourTree.h
+++ b/core/sql/sort/TourTree.h
@@ -65,6 +65,7 @@ class Tree : public SortAlgo { //SortAlgo inherits from NABasciObject
        CollHeap* heap,
        SortError* sorterror,
        Lng32 explainNodeId,
+       ExBMOStats *bmoStats,
        SortUtil* sortUtil,
        Lng32  runnum = 0,
        NABoolean  merge = FALSE_L,NABoolean waited = FALSE_L);


[4/7] incubator-trafodion git commit: [TRAFODION-2420] RMS enhancements

Posted by se...@apache.org.
[TRAFODION-2420] RMS enhancements

New counters introduced as part of BMO

InterimRowCount - Counter to keep track intermediate rows
                  produced by hash join and for intermediate
                  runs in sort
phase           - BMO Phase for hash-join and sort

get statistics for statement s1, options 'cs' now works.

Removed attaching BMO stats to Non-root Paritial and leaf partition hash group by operators.
These operators are non-blocking BMOs.

Introduced 3 phases for hash grby operator to be visible in RMS Stats

options 'sl' now works with get statistics for qid.

The relevant new counters are now part of accumulated statistics type.

Extended the support upto 512 opeartors from 256 operators in RMS

Fixed both Type 2 and mxosrvr code to obtain all the externalized counters in accumualted stats correctly.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/e7719015
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/e7719015
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/e7719015

Branch: refs/heads/master
Commit: e7719015286a0217fa5ec81551a783f8bc18fc3b
Parents: f60c1b0
Author: selvaganesang <se...@esgyn.com>
Authored: Mon May 1 23:11:47 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Tue May 9 04:01:43 2017 +0000

----------------------------------------------------------------------
 .../native/ResStatisticsStatement.cpp           |   72 +-
 .../jdbc_type2/native/ResStatisticsStatement.h  |    9 +
 .../odbc/nsksrvrcore/ResStatisticsStatement.cpp |   88 +-
 .../odbc/nsksrvrcore/ResStatisticsStatement.h   |    7 +
 core/sql/cli/sqlcli.h                           |    2 +
 core/sql/comexe/ComTdbHashGrby.h                |    2 +
 core/sql/executor/ExExeUtil.h                   |    8 +-
 core/sql/executor/ExExeUtilGetStats.cpp         |  444 ++--
 core/sql/executor/ExStats.cpp                   |  302 +--
 core/sql/executor/ExStats.h                     |   26 +-
 core/sql/executor/ex_hash_grby.cpp              |   21 +-
 core/sql/executor/ex_hash_grby.h                |   11 +
 core/sql/executor/ex_hashj.cpp                  |   26 +-
 core/sql/executor/ex_hashj.h                    |   18 +-
 core/sql/executor/ex_sort.cpp                   |   17 +-
 core/sql/executor/ex_sort.h                     |   12 +-
 core/sql/parser/sqlparser.y                     |    2 +-
 core/sql/regress/core/EXPECTEDRTS               | 1903 +++++++++---------
 core/sql/regress/core/FILTERRTS                 |   18 +-
 core/sql/sort/Qsort.cpp                         |    9 +-
 core/sql/sort/Qsort.h                           |    3 +-
 core/sql/sort/SortAlgo.cpp                      |    3 +-
 core/sql/sort/SortAlgo.h                        |    3 +-
 core/sql/sort/SortTopN.cpp                      |    9 +-
 core/sql/sort/SortTopN.h                        |    3 +-
 core/sql/sort/SortUtil.cpp                      |    8 +-
 core/sql/sort/TourTree.cpp                      |    8 +-
 core/sql/sort/TourTree.h                        |    1 +
 28 files changed, 1616 insertions(+), 1419 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/conn/jdbc_type2/native/ResStatisticsStatement.cpp
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/native/ResStatisticsStatement.cpp b/core/conn/jdbc_type2/native/ResStatisticsStatement.cpp
index 875ef3b..b3b9f54 100644
--- a/core/conn/jdbc_type2/native/ResStatisticsStatement.cpp
+++ b/core/conn/jdbc_type2/native/ResStatisticsStatement.cpp
@@ -134,6 +134,7 @@ ResStatisticsStatement::ResStatisticsStatement(bool useCLI)
     SpaceUsed = 0;
     HeapTotal = 0;
     HeapUsed = 0;
+    HeapWM = 0;
     CpuTime = 0;
     Dp2SpaceTotal = 0;
     Dp2SpaceUsed = 0;
@@ -156,7 +157,12 @@ ResStatisticsStatement::ResStatisticsStatement(bool useCLI)
     ScratchOverflowMode = 0;
     ScratchBufferReadCount = 0;
     ScratchBufferWriteCount = 0;
-
+    bmoSpaceBufferSize = 0;
+    bmoSpaceBufferCount = 0;
+    bmoInterimRowCount = 0;
+    ScratchIOSize = 0;
+    ScratchIOMaxTime = 0;
+    topN = 0;
     estimatedCost = 0;
 
     rtsExeCols = NULL;
@@ -1321,7 +1327,7 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
 #define MAX_PERTABLE_STATS_DESC     30
 
 #define MAX_MASTERSTATS_ENTRY       31
-#define MAX_MEASSTATS_ENTRY         26 
+#define MAX_MEASSTATS_ENTRY         27
 #define MAX_PERTABLE_ENTRY          10
 
     int i;
@@ -1545,23 +1551,27 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
                 measStatsItems_[7].statsItem_id = SQLSTATS_SQL_SPACE_USED;
                 measStatsItems_[8].statsItem_id = SQLSTATS_SQL_HEAP_ALLOC;
                 measStatsItems_[9].statsItem_id = SQLSTATS_SQL_HEAP_USED;
-                measStatsItems_[10].statsItem_id = SQLSTATS_OPENS;
-                measStatsItems_[11].statsItem_id = SQLSTATS_OPEN_TIME;
-                measStatsItems_[12].statsItem_id = SQLSTATS_PROCESS_CREATED;
-                measStatsItems_[13].statsItem_id = SQLSTATS_PROCESS_CREATE_TIME;
-                measStatsItems_[14].statsItem_id = SQLSTATS_REQ_MSG_CNT;
-                measStatsItems_[15].statsItem_id = SQLSTATS_REQ_MSG_BYTES;
-                measStatsItems_[16].statsItem_id = SQLSTATS_REPLY_MSG_CNT;
-                measStatsItems_[17].statsItem_id = SQLSTATS_REPLY_MSG_BYTES;
-                measStatsItems_[18].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
-                measStatsItems_[19].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE;
-                measStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ;
-                measStatsItems_[21].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN;
-                measStatsItems_[22].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
-                measStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
-                measStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
-                measStatsItems_[25].statsItem_id = SQLSTATS_UDR_CPU_BUSY_TIME;
-                // MAX_MEASSTATS_ENTRY is set to 26
+                measStatsItems_[10].statsItem_id = SQLSTATS_SQL_HEAP_WM;
+                measStatsItems_[11].statsItem_id = SQLSTATS_OPENS;
+                measStatsItems_[12].statsItem_id = SQLSTATS_OPEN_TIME;
+                measStatsItems_[13].statsItem_id = SQLSTATS_PROCESS_CREATED;
+                measStatsItems_[14].statsItem_id = SQLSTATS_PROCESS_CREATE_TIME;
+                measStatsItems_[15].statsItem_id = SQLSTATS_REQ_MSG_CNT;
+                measStatsItems_[16].statsItem_id = SQLSTATS_REQ_MSG_BYTES;
+                measStatsItems_[17].statsItem_id = SQLSTATS_REPLY_MSG_CNT;
+                measStatsItems_[18].statsItem_id = SQLSTATS_REPLY_MSG_BYTES;
+                measStatsItems_[19].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
+                measStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
+                measStatsItems_[21].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_SIZE;
+                measStatsItems_[22].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_COUNT;
+                measStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_IO_SIZE;
+                measStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
+                measStatsItems_[25].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
+                measStatsItems_[26].statsItem_id = SQLSTATS_SCRATCH_IO_MAX_TIME;
+                measStatsItems_[27].statsItem_id = SQLSTATS_INTERIM_ROW_COUNT;
+                measStatsItems_[28].statsItem_id = SQLSTATS_TOPN;
+                measStatsItems_[29].statsItem_id = SQLSTATS_UDR_CPU_BUSY_TIME;
+                // MAX_MEASSTATS_ENTRY is set to 30
 
                 cliRC = SQL_EXEC_GetStatisticsItems(
                     reqType,
@@ -1826,6 +1836,9 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
                 case SQLSTATS_SQL_HEAP_USED:            //int64
                     HeapUsed = measStatsItems_[i].int64_value;
                     break;
+                case SQLSTATS_SQL_HEAP_WM:            //int64
+                    HeapWM = measStatsItems_[i].int64_value;
+                    break;
                 case SQLSTATS_OPENS:                    //int64
                     Opens = measStatsItems_[i].int64_value;
                     break;
@@ -1853,14 +1866,14 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
                 case SQLSTATS_SCRATCH_FILE_COUNT:
                     ScratchFileCount = measStatsItems_[i].int64_value;
                     break;
-                case SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE:
-                    ScratchBufferBlockSize = measStatsItems_[i].int64_value;
+                case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
+                    bmoSpaceBufferSize = measStatsItems_[i].int64_value;
                     break;
-                case SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ:
-                    ScratchBufferBlocksRead = measStatsItems_[i].int64_value;
+                case SQLSTATS_BMO_SPACE_BUFFER_COUNT:
+                    bmoSpaceBufferCount = measStatsItems_[i].int64_value;
                     break;
-                case SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN:
-                    ScratchBufferBlocksWritten = measStatsItems_[i].int64_value;
+                case SQLSTATS_SCRATCH_IO_SIZE:
+                    ScratchIOSize = measStatsItems_[i].int64_value;
                     break;
                 case SQLSTATS_SCRATCH_OVERFLOW_MODE:
                     ScratchOverflowMode = (short)measStatsItems_[i].int64_value;
@@ -1871,6 +1884,15 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
                 case SQLSTATS_SCRATCH_WRITE_COUNT:
                     ScratchBufferWriteCount = measStatsItems_[i].int64_value;
                     break;
+                case SQLSTATS_SCRATCH_IO_MAX_TIME:
+                    ScratchIOMaxTime = measStatsItems_[i].int64_value;
+                    break;
+                case SQLSTATS_INTERIM_ROW_COUNT:
+                    bmoInterimRowCount = measStatsItems_[i].int64_value;
+                    break;
+                case SQLSTATS_TOPN:
+                    topN = measStatsItems_[i].int64_value;
+                    break;
                 case SQLSTATS_UDR_CPU_BUSY_TIME:
                     UdrCpuTime = measStatsItems_[i].int64_value;
                     break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/conn/jdbc_type2/native/ResStatisticsStatement.h
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/native/ResStatisticsStatement.h b/core/conn/jdbc_type2/native/ResStatisticsStatement.h
index eb7bf5f..fe63a88 100644
--- a/core/conn/jdbc_type2/native/ResStatisticsStatement.h
+++ b/core/conn/jdbc_type2/native/ResStatisticsStatement.h
@@ -153,6 +153,12 @@ private:
      short      ScratchOverflowMode;
      int64      ScratchBufferReadCount;
      int64      ScratchBufferWriteCount;
+     int64	ScratchIOMaxTime;
+     int32      ScratchIOSize;
+     int32      bmoSpaceBufferSize;
+     int64      bmoSpaceBufferCount;
+     int64      bmoInterimRowCount;
+     int32      topN;
      char        subQryType[SUB_QRY_TYPE_LEN+1];
      char        parentSysName[PAR_SYS_NAME_LEN+1];
 
@@ -176,12 +182,15 @@ private:
      Int64        SpaceUsed;                //YES
      Int64        HeapTotal;                //YES
      Int64        HeapUsed;             //YES
+     Int64        HeapWM;
      int64   CpuTime;
      Int64        Dp2SpaceTotal;            //YES
      Int64        Dp2SpaceUsed;         //YES
      Int64        Dp2HeapTotal;         //YES
      Int64        Dp2HeapUsed;          //YES
 
+
+
      // Currently not in R2.5. To be enabled post R2.5/SQ
      int64       UdrCpuTime;            //YES
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.cpp b/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.cpp
index f71af4b..ebebde8 100644
--- a/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.cpp
@@ -119,6 +119,7 @@ ResStatisticsStatement::ResStatisticsStatement(bool useCLI)
 	SpaceUsed = 0;
 	HeapTotal = 0;
 	HeapUsed = 0;
+        HeapWM = 0;
 	CpuTime = 0;
 	Dp2SpaceTotal = 0;
 	Dp2SpaceUsed = 0;
@@ -141,7 +142,12 @@ ResStatisticsStatement::ResStatisticsStatement(bool useCLI)
 	ScratchOverflowMode = 0;
 	ScratchBufferReadCount = 0;
 	ScratchBufferWriteCount = 0;
-
+	bmoSpaceBufferSize = 0;
+	bmoSpaceBufferCount = 0;
+	bmoInterimRowCount = 0;
+	ScratchIOSize = 0;
+	ScratchIOMaxTime = 0;
+	topN = 0;
 	estimatedCost = 0;
 
 	rtsExeCols = NULL;
@@ -252,6 +258,7 @@ void ResStatisticsStatement::init()
 	SpaceUsed = 0;
 	HeapTotal = 0;
 	HeapUsed = 0;
+        HeapWM = 0;
 	CpuTime = 0;
 	Dp2SpaceTotal = 0;
 	Dp2SpaceUsed = 0;
@@ -276,6 +283,12 @@ void ResStatisticsStatement::init()
 	ScratchOverflowMode = 0;
 	ScratchBufferReadCount = 0;
 	ScratchBufferWriteCount = 0;
+	bmoSpaceBufferSize = 0;
+	bmoSpaceBufferCount = 0;
+	bmoInterimRowCount = 0;
+	ScratchIOSize = 0;
+	ScratchIOMaxTime = 0;
+	topN = 0;
 }
 //
 string getSrvrSubstate(NDCS_SUBSTATE mx_substate)
@@ -1202,6 +1215,7 @@ void ResStatisticsStatement::init_rms_counters(bool resetAll)
 		SpaceUsed = 0;
 		HeapTotal = 0;
 		HeapUsed = 0;
+                HeapWM = 0;
 		CpuTime = 0;
 		Dp2SpaceTotal = 0;
 		Dp2SpaceUsed = 0;
@@ -1256,6 +1270,12 @@ void ResStatisticsStatement::init_rms_counters(bool resetAll)
 		ScratchOverflowMode = 0;
 		ScratchBufferReadCount = 0;
 		ScratchBufferWriteCount = 0;	
+		bmoSpaceBufferSize = 0;
+		bmoSpaceBufferCount = 0;
+		bmoInterimRowCount = 0;
+		ScratchIOSize = 0;
+		ScratchIOMaxTime = 0;
+		topN = 0;
 }
 
 void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TYPE statsType, char *qID, short qIdLen ,int activeQueryNum)//20111208
@@ -1265,8 +1285,8 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
 #define MAX_PERTABLE_STATS_DESC		30
 
 #define MAX_MASTERSTATS_ENTRY		31
-#define MAX_MEASSTATS_ENTRY			26
-#define MAX_PERTABLE_ENTRY			10
+#define MAX_MEASSTATS_ENTRY		30	
+#define MAX_PERTABLE_ENTRY		10
 
 	int i;
 	Int32 cliRC;
@@ -1489,23 +1509,27 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
 				measStatsItems_[7].statsItem_id = SQLSTATS_SQL_SPACE_USED;
 				measStatsItems_[8].statsItem_id = SQLSTATS_SQL_HEAP_ALLOC;
 				measStatsItems_[9].statsItem_id = SQLSTATS_SQL_HEAP_USED;
-				measStatsItems_[10].statsItem_id = SQLSTATS_OPENS;
-				measStatsItems_[11].statsItem_id = SQLSTATS_OPEN_TIME;
-				measStatsItems_[12].statsItem_id = SQLSTATS_PROCESS_CREATED;
-				measStatsItems_[13].statsItem_id = SQLSTATS_PROCESS_CREATE_TIME;
-				measStatsItems_[14].statsItem_id = SQLSTATS_REQ_MSG_CNT;
-				measStatsItems_[15].statsItem_id = SQLSTATS_REQ_MSG_BYTES;
-				measStatsItems_[16].statsItem_id = SQLSTATS_REPLY_MSG_CNT;
-				measStatsItems_[17].statsItem_id = SQLSTATS_REPLY_MSG_BYTES;
-				measStatsItems_[18].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
-				measStatsItems_[19].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE;
-				measStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ;
-				measStatsItems_[21].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN;
-				measStatsItems_[22].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
-				measStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
-				measStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
-				measStatsItems_[25].statsItem_id = SQLSTATS_UDR_CPU_BUSY_TIME;
-				// MAX_MEASSTATS_ENTRY is set to 26 
+				measStatsItems_[10].statsItem_id = SQLSTATS_SQL_HEAP_WM;
+				measStatsItems_[11].statsItem_id = SQLSTATS_OPENS;
+				measStatsItems_[12].statsItem_id = SQLSTATS_OPEN_TIME;
+				measStatsItems_[13].statsItem_id = SQLSTATS_PROCESS_CREATED;
+				measStatsItems_[14].statsItem_id = SQLSTATS_PROCESS_CREATE_TIME;
+				measStatsItems_[15].statsItem_id = SQLSTATS_REQ_MSG_CNT;
+				measStatsItems_[16].statsItem_id = SQLSTATS_REQ_MSG_BYTES;
+				measStatsItems_[17].statsItem_id = SQLSTATS_REPLY_MSG_CNT;
+				measStatsItems_[18].statsItem_id = SQLSTATS_REPLY_MSG_BYTES;
+				measStatsItems_[19].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
+				measStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
+				measStatsItems_[21].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_SIZE;
+				measStatsItems_[22].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_COUNT;
+				measStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_IO_SIZE;
+				measStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
+				measStatsItems_[25].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
+				measStatsItems_[26].statsItem_id = SQLSTATS_SCRATCH_IO_MAX_TIME;
+				measStatsItems_[27].statsItem_id = SQLSTATS_INTERIM_ROW_COUNT;
+				measStatsItems_[28].statsItem_id = SQLSTATS_TOPN;
+				measStatsItems_[29].statsItem_id = SQLSTATS_UDR_CPU_BUSY_TIME;
+				// MAX_MEASSTATS_ENTRY is set to 30
 
 				cliRC = SQL_EXEC_GetStatisticsItems(
 					reqType,
@@ -1770,6 +1794,9 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
 				case SQLSTATS_SQL_HEAP_USED:			//int64
 					HeapUsed = measStatsItems_[i].int64_value;
 					break;
+				case SQLSTATS_SQL_HEAP_WM:           //int64
+					HeapWM = measStatsItems_[i].int64_value;
+					break;
 				case SQLSTATS_OPENS:					//int64
 					Opens = measStatsItems_[i].int64_value;
 					break;
@@ -1797,14 +1824,14 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
 				case SQLSTATS_SCRATCH_FILE_COUNT:
 					ScratchFileCount = measStatsItems_[i].int64_value;
 					break;
-				case SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE:
-					ScratchBufferBlockSize = measStatsItems_[i].int64_value;
+				case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
+					bmoSpaceBufferSize = measStatsItems_[i].int64_value;
 					break;
-				case SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ:
-					ScratchBufferBlocksRead = measStatsItems_[i].int64_value;
+				case SQLSTATS_BMO_SPACE_BUFFER_COUNT:
+					bmoSpaceBufferCount = measStatsItems_[i].int64_value;
 					break;
-				case SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN:
-					ScratchBufferBlocksWritten = measStatsItems_[i].int64_value;
+				case SQLSTATS_SCRATCH_IO_SIZE:
+					ScratchIOSize = measStatsItems_[i].int64_value;
 					break;
 				case SQLSTATS_SCRATCH_OVERFLOW_MODE:
 					ScratchOverflowMode = (short)measStatsItems_[i].int64_value;
@@ -1815,6 +1842,15 @@ void ResStatisticsStatement::setStatistics(SRVR_STMT_HDL *pSrvrStmt, SQLSTATS_TY
 				case SQLSTATS_SCRATCH_WRITE_COUNT:
 					ScratchBufferWriteCount = measStatsItems_[i].int64_value;
 					break;
+				case SQLSTATS_SCRATCH_IO_MAX_TIME:
+					ScratchIOMaxTime = measStatsItems_[i].int64_value;
+					break;
+				case SQLSTATS_INTERIM_ROW_COUNT:
+					bmoInterimRowCount = measStatsItems_[i].int64_value;
+					break;
+				case SQLSTATS_TOPN:
+					topN = measStatsItems_[i].int64_value;
+					break;
 				case SQLSTATS_UDR_CPU_BUSY_TIME:
 					UdrCpuTime = measStatsItems_[i].int64_value;
 					break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.h b/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.h
index 1f966d4..c0d00bd 100644
--- a/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.h
+++ b/core/conn/odbc/src/odbc/nsksrvrcore/ResStatisticsStatement.h
@@ -145,6 +145,12 @@ private:
 	 short		ScratchOverflowMode;
 	 int64		ScratchBufferReadCount;
 	 int64		ScratchBufferWriteCount;
+	 int32		ScratchIOSize;
+	 int32		ScratchIOMaxTime;
+	 int32		bmoSpaceBufferSize;
+	 int64		bmoSpaceBufferCount;
+	 int64		bmoInterimRowCount;
+	 int32		topN;
 	 char        subQryType[SUB_QRY_TYPE_LEN+1];
 	 char        parentSysName[PAR_SYS_NAME_LEN+1];
 
@@ -168,6 +174,7 @@ private:
 	 Int64        SpaceUsed;				//YES
 	 Int64        HeapTotal;				//YES
 	 Int64        HeapUsed;				//YES
+         Int64        HeapWM;
 	 int64   CpuTime;
 	 Int64        Dp2SpaceTotal;			//YES
 	 Int64        Dp2SpaceUsed;			//YES

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/cli/sqlcli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/sqlcli.h b/core/sql/cli/sqlcli.h
index dfe04a3..19d2f1b 100644
--- a/core/sql/cli/sqlcli.h
+++ b/core/sql/cli/sqlcli.h
@@ -1180,6 +1180,8 @@ enum SQLSTATS_ITEM_ID {
   SQLSTATS_SCRATCH_READ_COUNT = 162,
   SQLSTATS_SCRATCH_WRITE_COUNT = 163,
   SQLSTATS_SCRATCH_IO_MAX_TIME = 164,
+  SQLSTATS_BMO_PHASE = 166,
+  SQLSTATS_INTERIM_ROW_COUNT = 167,
 /* SQLSTATS_ITEM_ID for UDR_BASE_STATS */
   SQLSTATS_UDR_CPU_BUSY_TIME = 170,
   SQLSTATS_RECENT_REQ_TS = 171,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/comexe/ComTdbHashGrby.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbHashGrby.h b/core/sql/comexe/ComTdbHashGrby.h
index b787c24..79fb444 100644
--- a/core/sql/comexe/ComTdbHashGrby.h
+++ b/core/sql/comexe/ComTdbHashGrby.h
@@ -361,6 +361,8 @@ NA_EIDPROC
   UInt16  getBMOMaxMemThresholdMB()
   { return bmoMaxMemThresholdMB_; }
 
+  NABoolean isNonBMOPartialGroupBy() { return (isPartialGroup_ == TRUE); }
+
 };
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index b67e956..6a86996 100755
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -69,10 +69,10 @@ class ExpHbaseInterface;
 
 #define TO_FMT3u(u) MINOF(((u)+500)/1000, 999)
 #define MAX_ACCUMULATED_STATS_DESC 2
-#define MAX_PERTABLE_STATS_DESC    30
-#define MAX_PROGRESS_STATS_DESC    50
-#define MAX_OPERATOR_STATS_DESC    256
-#define MAX_RMS_STATS_DESC         256
+#define MAX_PERTABLE_STATS_DESC    256
+#define MAX_PROGRESS_STATS_DESC    256 
+#define MAX_OPERATOR_STATS_DESC    512
+#define MAX_RMS_STATS_DESC         512
 #define BUFFER_SIZE 4000
 #define MAX_AUTHIDTYPE_CHAR        11
 #define MAX_USERINFO_CHAR          257

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ExExeUtilGetStats.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilGetStats.cpp b/core/sql/executor/ExExeUtilGetStats.cpp
index 6188ccd..09057df 100644
--- a/core/sql/executor/ExExeUtilGetStats.cpp
+++ b/core/sql/executor/ExExeUtilGetStats.cpp
@@ -64,7 +64,13 @@ ex_tcb * ExExeUtilGetStatisticsTdb::build(ex_globals * glob)
     if (getStmtName() == NULL)
        exe_util_tcb = new(glob->getSpace()) ExExeUtilGetStatisticsTcb(*this, glob);
     else
-       exe_util_tcb = new(glob->getSpace()) ExExeUtilGetRTSStatisticsTcb(*this, glob);
+    {
+       if (compilerStats() || executorStats() || otherStats() || detailedStats() ||
+               oldFormat() || shortFormat() || tokenizedFormat())
+          exe_util_tcb = new(glob->getSpace()) ExExeUtilGetStatisticsTcb(*this, glob);
+       else
+          exe_util_tcb = new(glob->getSpace()) ExExeUtilGetRTSStatisticsTcb(*this, glob);
+    }
     break;
   case SQLCLI_STATS_REQ_QID:
   case SQLCLI_STATS_REQ_QID_INTERNAL:
@@ -2317,7 +2323,7 @@ short ExExeUtilGetRTSStatisticsTcb::work()
       {
         if (measStatsItems_ == NULL)
         {
-          maxMeasStatsItems_ = 28;
+          maxMeasStatsItems_ = 30;
           measStatsItems_ = new (getGlobals()->getDefaultHeap()) 
                   SQLSTATS_ITEM[maxMeasStatsItems_];
           initSqlStatsItems(measStatsItems_, maxMeasStatsItems_, FALSE);
@@ -2341,15 +2347,17 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           measStatsItems_[17].statsItem_id = SQLSTATS_REQ_MSG_BYTES;
           measStatsItems_[18].statsItem_id = SQLSTATS_REPLY_MSG_CNT;
           measStatsItems_[19].statsItem_id = SQLSTATS_REPLY_MSG_BYTES;
-          measStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
-          measStatsItems_[21].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
-          measStatsItems_[22].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE;
-          measStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ;
-          measStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN;
-          measStatsItems_[25].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
-          measStatsItems_[26].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
-          measStatsItems_[27].statsItem_id = SQLSTATS_TOPN;
-          // maxMeasStatsItems_ is set to  28
+          measStatsItems_[20].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_SIZE;
+          measStatsItems_[21].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_COUNT;
+          measStatsItems_[22].statsItem_id = SQLSTATS_INTERIM_ROW_COUNT;
+          measStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
+          measStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
+          measStatsItems_[25].statsItem_id = SQLSTATS_SCRATCH_IO_SIZE;
+          measStatsItems_[26].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
+          measStatsItems_[27].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
+          measStatsItems_[28].statsItem_id = SQLSTATS_SCRATCH_IO_MAX_TIME;
+          measStatsItems_[29].statsItem_id = SQLSTATS_TOPN;
+          // maxMeasStatsItems_ is set to  30
         }
         else
           initSqlStatsItems(measStatsItems_, maxMeasStatsItems_, TRUE);
@@ -2511,23 +2519,17 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             AddCommas(Int64Val,intSize); 
             str_sprintf(statsBuf_, "%25s%s", "Scr. File Count", Int64Val);
             break;
-          case SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE:
-            str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            str_sprintf(statsBuf_, "%25s%s", "Scr. Buffer Blk Size", Int64Val);
-            break;
-          case SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ:
+          case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
             str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(statsBuf_, "%25s%s", "Scr. Buffer Blks Read", Int64Val);
+            str_sprintf(statsBuf_, "%25s%s", "BMO Space Buffer Size", Int64Val);
             break;
-          case SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN:
+          case SQLSTATS_BMO_SPACE_BUFFER_COUNT:
             str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(statsBuf_, "%25s%s", "Scr. Buffer Blks Written", Int64Val);
+            str_sprintf(statsBuf_, "%25s%s", "BMO Space Buffer Count", Int64Val);
             break;
           case SQLSTATS_SCRATCH_READ_COUNT:
             str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
@@ -2541,6 +2543,24 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             AddCommas(Int64Val,intSize); 
             str_sprintf(statsBuf_, "%25s%s", "Scr. Write Count", Int64Val);
             break;
+          case SQLSTATS_SCRATCH_IO_SIZE:
+            str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
+            intSize = str_len(Int64Val);
+            AddCommas(Int64Val,intSize); 
+            str_sprintf(statsBuf_, "%25s%s", "Scr. IO Size", Int64Val);
+            break;
+          case SQLSTATS_SCRATCH_IO_MAX_TIME:
+            str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
+            intSize = str_len(Int64Val);
+            AddCommas(Int64Val,intSize); 
+            str_sprintf(statsBuf_, "%25s%s", "Scr. IO Max Time", Int64Val);
+            break;
+          case SQLSTATS_INTERIM_ROW_COUNT:
+            str_sprintf(Int64Val, "%Ld", measStatsItems_[i].int64_value);
+            intSize = str_len(Int64Val);
+            AddCommas(Int64Val,intSize); 
+            str_sprintf(statsBuf_, "%25s%s", "BMO Interim Row Count", Int64Val);
+            break;
           default:
             statsBuf_[0] = '\0';
             break;
@@ -2555,7 +2575,7 @@ short ExExeUtilGetRTSStatisticsTcb::work()
       {
         if (rootOperStatsItems_ == NULL)
         {
-          maxRootOperStatsItems_ = 25;
+          maxRootOperStatsItems_ = 27;
           rootOperStatsItems_ = new (getGlobals()->getDefaultHeap()) 
                   SQLSTATS_ITEM[maxRootOperStatsItems_];
           initSqlStatsItems(rootOperStatsItems_, maxRootOperStatsItems_, FALSE);
@@ -2576,15 +2596,17 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           rootOperStatsItems_[14].statsItem_id = SQLSTATS_REQ_MSG_BYTES;
           rootOperStatsItems_[15].statsItem_id = SQLSTATS_REPLY_MSG_CNT;
           rootOperStatsItems_[16].statsItem_id = SQLSTATS_REPLY_MSG_BYTES;
-          rootOperStatsItems_[17].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
-          rootOperStatsItems_[18].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
-          rootOperStatsItems_[19].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE;
-          rootOperStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ;
-          rootOperStatsItems_[21].statsItem_id = SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN;
-          rootOperStatsItems_[22].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
-          rootOperStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
-          rootOperStatsItems_[24].statsItem_id = SQLSTATS_TOPN;
-          // maxRootOperStatsItems_ is set to 25
+          rootOperStatsItems_[17].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_SIZE;
+          rootOperStatsItems_[18].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_COUNT;
+          rootOperStatsItems_[19].statsItem_id = SQLSTATS_INTERIM_ROW_COUNT;
+          rootOperStatsItems_[20].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
+          rootOperStatsItems_[21].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
+          rootOperStatsItems_[22].statsItem_id = SQLSTATS_SCRATCH_IO_SIZE;
+          rootOperStatsItems_[23].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
+          rootOperStatsItems_[24].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
+          rootOperStatsItems_[25].statsItem_id = SQLSTATS_SCRATCH_IO_MAX_TIME;
+          rootOperStatsItems_[26].statsItem_id = SQLSTATS_TOPN;
+          // maxRootOperStatsItems_ is set to 27
         }
         else
           initSqlStatsItems(rootOperStatsItems_, maxRootOperStatsItems_, TRUE);
@@ -2705,47 +2727,47 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             else
               continue;
             break;
-          case SQLSTATS_TOPN:
+          case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
             if (statsMergeType != SQLCLI_PROGRESS_STATS)
             {
               formatWInt64( rootOperStatsItems_[i], Int64Val);
-              str_sprintf(statsBuf_, "%25s%s", "Sort TopN", Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "BMO Space Buffer Size", Int64Val);
             }
             else
               continue;
             break;
-          case SQLSTATS_SCRATCH_FILE_COUNT:
+          case SQLSTATS_BMO_SPACE_BUFFER_COUNT:
             if (statsMergeType != SQLCLI_PROGRESS_STATS)
             {
               formatWInt64( rootOperStatsItems_[i], Int64Val);
-              str_sprintf(statsBuf_, "%25s%s", "Scr. File Count", Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "BMO Space Buffer Count", Int64Val);
             }
             else
               continue;
             break;
-          case SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE:
+          case SQLSTATS_TOPN:
             if (statsMergeType != SQLCLI_PROGRESS_STATS)
             {
               formatWInt64( rootOperStatsItems_[i], Int64Val);
-              str_sprintf(statsBuf_, "%25s%s", "Scr. Buffer Blk Size", Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "Sort TopN", Int64Val);
             }
             else
               continue;
             break;
-          case SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ:
+          case SQLSTATS_SCRATCH_FILE_COUNT:
             if (statsMergeType != SQLCLI_PROGRESS_STATS)
             {
               formatWInt64( rootOperStatsItems_[i], Int64Val);
-              str_sprintf(statsBuf_, "%25s%s", "Scr. Buffer Blks Read", Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "Scr. File Count", Int64Val);
             }
             else
               continue;
             break;
-          case SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN:
+          case SQLSTATS_SCRATCH_IO_SIZE:
             if (statsMergeType != SQLCLI_PROGRESS_STATS)
             {
               formatWInt64( rootOperStatsItems_[i], Int64Val);
-              str_sprintf(statsBuf_, "%25s%s", "Scr. Buffer Blks Written", Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "Scr. IO Size", Int64Val);
             }
             else
               continue;
@@ -2768,6 +2790,24 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             else
               continue;
             break;
+          case SQLSTATS_SCRATCH_IO_MAX_TIME:
+            if (statsMergeType != SQLCLI_PROGRESS_STATS)
+            {
+              formatWInt64( rootOperStatsItems_[i], Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "Scr. IO Max Time", Int64Val);
+            }
+            else
+              continue;
+            break;
+          case SQLSTATS_INTERIM_ROW_COUNT:
+            if (statsMergeType != SQLCLI_PROGRESS_STATS)
+            {
+              formatWInt64( rootOperStatsItems_[i], Int64Val);
+              str_sprintf(statsBuf_, "%25s%s", "BMO Interim Row Count", Int64Val);
+            }
+            else
+              continue;
+            break;
           default:
             statsBuf_[0] = '\0';
             break;
@@ -2790,8 +2830,8 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           hbaseStatsItems_[1].statsItem_id = SQLSTATS_DOP;
           hbaseStatsItems_[2].statsItem_id = SQLSTATS_TABLE_ANSI_NAME;
           hbaseStatsItems_[3].statsItem_id = SQLSTATS_EST_ROWS_ACCESSED;
-          hbaseStatsItems_[4].statsItem_id = SQLSTATS_EST_ROWS_USED;
-          hbaseStatsItems_[5].statsItem_id = SQLSTATS_ACT_ROWS_ACCESSED;
+          hbaseStatsItems_[4].statsItem_id = SQLSTATS_ACT_ROWS_ACCESSED;
+          hbaseStatsItems_[5].statsItem_id = SQLSTATS_EST_ROWS_USED;
           hbaseStatsItems_[6].statsItem_id = SQLSTATS_ACT_ROWS_USED;
           hbaseStatsItems_[7].statsItem_id = SQLSTATS_HBASE_IOS;
           hbaseStatsItems_[8].statsItem_id = SQLSTATS_HBASE_IO_BYTES;
@@ -2824,122 +2864,126 @@ short ExExeUtilGetRTSStatisticsTcb::work()
       }
       break;
     case DISPLAY_HBASE_STATS_HEADING_:
+    case DISPLAY_HIVE_STATS_HEADING_:
       {
         if ((qparent_.up->getSize() - qparent_.up->getLength()) < 5)
 	      return WORK_CALL_AGAIN;
         moveRowToUpQueue(" ");
         if (singleLineFormat_) {
-           str_sprintf(statsBuf_, "%-9s%-10s%-19s%-19s%-19s%-19s%-13s%-13s%-19s%-19s%-10s",
-                "ID", "DOP",
-                "EstRowsAccessed", "EstRecordsUsed",  "ActRowsAccessed", "ActRowsUsed", "SE_IOs",
+           str_sprintf(statsBuf_, "%-5s%-10s%-15s%-20s%-15s%-20s%-20s%-20s%-20s%-20s%-10s",
+                "Id", "DOP",
+                "EstRowsAccess", "ActRowsAccess", "EstRowUsed", "ActRowsUsed", "SE_IOs",
                 "SE_IO_Bytes", "SE_IO_SumTime", "SE_IO_MaxTime", "TableName");
            moveRowToUpQueue(statsBuf_);
         }
         else {
-           str_sprintf(statsBuf_, "%-9s%-10s%-19s", 
-                "ID", "DOP","Table Name");
+           str_sprintf(statsBuf_, "%-5s%-10s%-20s", 
+                "Id", "DOP","Table Name");
 	   moveRowToUpQueue(statsBuf_);
-           str_sprintf(statsBuf_, "%-19s%-19s%-13s%-13s%-19s%-19s",
-		"Records Accessed", "Records Used", "HBase/Hive", "HBase/Hive", 
-                "HBase/Hive IO", "HBase/Hive IO");
-           moveRowToUpQueue(statsBuf_);
-	   str_sprintf(statsBuf_, "%-19s%-19s%-13s%-13s%-19s%-19s",
-		"Estimated/Actual", "Estimated/Actual", "IOs", "IO MBytes",
-                "Sum Time", "Max Time");
+           str_sprintf(statsBuf_, "%-15s%-20s%-15s%-20s%-20s%-20s%-20s%-20s",
+		"EstRowsAccess", "ActRowsAccess", "EstRowsUsed", "ActRowsUsed", "SE_IOs", "SE_IO_Bytes", "SE_IO_SumTime", "SE_IO_MaxTime");
            moveRowToUpQueue(statsBuf_);
         }
         isHeadingDisplayed_ = TRUE;
-        step_ = FORMAT_AND_RETURN_HBASE_STATS_;
+        if (step_ == DISPLAY_HBASE_STATS_HEADING_)
+           step_ = FORMAT_AND_RETURN_HBASE_STATS_;
+        else
+           step_ = FORMAT_AND_RETURN_HIVE_STATS_;
       }
       break;
     case FORMAT_AND_RETURN_HBASE_STATS_:
+    case FORMAT_AND_RETURN_HIVE_STATS_:
       {
         short tableNameIndex = 2;
-        for (; currStatsItemEntry_ < maxHbaseStatsItems_; currStatsItemEntry_++)
+        SQLSTATS_ITEM *statsItems;
+        Lng32 maxStatsItems;
+
+        if (step_ == FORMAT_AND_RETURN_HBASE_STATS_) {
+           statsItems = hbaseStatsItems_;
+           maxStatsItems = maxHbaseStatsItems_;
+        }
+        else {
+           statsItems = hiveStatsItems_;
+           maxStatsItems = maxHiveStatsItems_;
+        } 
+        for (; currStatsItemEntry_ < maxStatsItems; currStatsItemEntry_++)
         {
           i = (short)currStatsItemEntry_;
-          if (hbaseStatsItems_[i].error_code != 0)
+          if (statsItems[i].error_code != 0)
             continue;
-          switch (hbaseStatsItems_[i].statsItem_id)
+          switch (statsItems[i].statsItem_id)
           {
           case SQLSTATS_TDB_ID:
-            str_sprintf(statsBuf_, "%-9Ld", hbaseStatsItems_[i].int64_value);
+            str_sprintf(statsBuf_, "%-5Ld", statsItems[i].int64_value);
             break;
           case SQLSTATS_DOP:
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10Ld", hbaseStatsItems_[i].int64_value);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10Ld", statsItems[i].int64_value);
             break;
           case SQLSTATS_TABLE_ANSI_NAME:
-            hbaseStatsItems_[i].str_value[hbaseStatsItems_[i].str_ret_len] = '\0';
+            statsItems[i].str_value[statsItems[i].str_ret_len] = '\0';
             if (singleLineFormat_)
                tableNameIndex = i;
             else {
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "   %s", hbaseStatsItems_[i].str_value);
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "   %s", statsItems[i].str_value);
                if (moveRowToUpQueue(statsBuf_, strlen(statsBuf_), &rc) == -1)
                   return rc;
             }
             break;
           case SQLSTATS_EST_ROWS_ACCESSED:
-            FormatFloat(formattedFloatVal, intSize, valSize, hbaseStatsItems_[i].double_value,
+            FormatFloat(formattedFloatVal, intSize, valSize, statsItems[i].double_value,
 			FALSE, TRUE);
             if (singleLineFormat_)
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", formattedFloatVal);
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-15s", formattedFloatVal);
             else
-               str_sprintf(statsBuf_, "%-19s", formattedFloatVal);
+               str_sprintf(statsBuf_, "%-15s", formattedFloatVal);
             break;
           case SQLSTATS_EST_ROWS_USED:
-            FormatFloat(formattedFloatVal, intSize, valSize, hbaseStatsItems_[i].double_value,
+            FormatFloat(formattedFloatVal, intSize, valSize, statsItems[i].double_value,
 			FALSE, TRUE);
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", formattedFloatVal);
-            if (! singleLineFormat_) {
-               if (moveRowToUpQueue(statsBuf_, strlen(statsBuf_), &rc) == -1)
-                  return rc;
-            }
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-15s", formattedFloatVal);
             break;
           case SQLSTATS_ACT_ROWS_ACCESSED:
-            str_sprintf(Int64Val, "%Ld", hbaseStatsItems_[i].int64_value);
+            str_sprintf(Int64Val, "%Ld", statsItems[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            if (singleLineFormat_)
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
-            else
-               str_sprintf(statsBuf_, "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;          
           case SQLSTATS_ACT_ROWS_USED:
-            str_sprintf(Int64Val, "%Ld", hbaseStatsItems_[i].int64_value);
+            str_sprintf(Int64Val, "%Ld", statsItems[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_HBASE_IOS:
-           str_sprintf(Int64Val, "%Ld", hbaseStatsItems_[i].int64_value);
+           str_sprintf(Int64Val, "%Ld", statsItems[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-13s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_HBASE_IO_BYTES:
-            str_sprintf(Int64Val, "%Ld", hbaseStatsItems_[i].int64_value/1024/1024);
+            str_sprintf(Int64Val, "%Ld", statsItems[i].int64_value/1024/1024);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-13s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_HBASE_IO_ELAPSED_TIME:
-            str_sprintf(Int64Val, "%Ld", hbaseStatsItems_[i].int64_value);
+            str_sprintf(Int64Val, "%Ld", statsItems[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_HBASE_IO_MAX_TIME:
-            str_sprintf(Int64Val, "%Ld", hbaseStatsItems_[i].int64_value);
+            str_sprintf(Int64Val, "%Ld", statsItems[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           default:
             break;
           }
         }
         if (singleLineFormat_)
-           str_sprintf(&statsBuf_[strlen(statsBuf_)], " %s", hbaseStatsItems_[2].str_value);
+           str_sprintf(&statsBuf_[strlen(statsBuf_)], " %s", statsItems[2].str_value);
         if (moveRowToUpQueue(statsBuf_, strlen(statsBuf_), &rc) == -1)
           return rc;
         step_ = GET_NEXT_STATS_DESC_ENTRY_;
@@ -2957,8 +3001,8 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           hiveStatsItems_[1].statsItem_id = SQLSTATS_DOP;
           hiveStatsItems_[2].statsItem_id = SQLSTATS_TABLE_ANSI_NAME;
           hiveStatsItems_[3].statsItem_id = SQLSTATS_EST_ROWS_ACCESSED;
-          hiveStatsItems_[4].statsItem_id = SQLSTATS_EST_ROWS_USED;
-          hiveStatsItems_[5].statsItem_id = SQLSTATS_ACT_ROWS_ACCESSED;
+          hiveStatsItems_[4].statsItem_id = SQLSTATS_ACT_ROWS_ACCESSED;
+          hiveStatsItems_[5].statsItem_id = SQLSTATS_EST_ROWS_USED;
           hiveStatsItems_[6].statsItem_id = SQLSTATS_ACT_ROWS_USED;
           hiveStatsItems_[7].statsItem_id = SQLSTATS_HIVE_IOS;
           hiveStatsItems_[8].statsItem_id = SQLSTATS_HIVE_IO_BYTES;
@@ -2990,132 +3034,11 @@ short ExExeUtilGetRTSStatisticsTcb::work()
         }
       }
       break;
-    case DISPLAY_HIVE_STATS_HEADING_:
-      {
-        if ((qparent_.up->getSize() - qparent_.up->getLength()) < 5)
-	      return WORK_CALL_AGAIN;
-        moveRowToUpQueue(" ");
-        if (singleLineFormat_) {
-           str_sprintf(statsBuf_, "%-9s%-10s%-19s%-19s%-19s%-19s%-13s%-13s%-19s%-19s%-10s",
-                "ID", "DOP",
-                "EstRowsAccessed", "EstRecordsUsed",  "ActRowsAccessed", "ActRowsUsed", "SE_IOs",
-                "SE_IO_Bytes", "SE_IO_SumTime", "SE_IO_MaxTime", "TableName");
-           moveRowToUpQueue(statsBuf_);
-        }
-        else {
-           str_sprintf(statsBuf_, "%-9s%-10s%-19s", "ID", "DOP","Table Name");
-	   moveRowToUpQueue(statsBuf_);
-           str_sprintf(statsBuf_, "%-19s%-19s%-13s%-13s%-19s%-19s",
-		"Records Accessed", "Records Used", "HBase/Hive", "HBase/Hive", 
-                "HBase/Hive IO", "HBase/Hive IO");
-           moveRowToUpQueue(statsBuf_);
-	   str_sprintf(statsBuf_, "%-19s%-19s%-13s%-13s%-19s%-19s",
-		"Estimated/Actual", "Estimated/Actual", "IOs", "IO MBytes",
-                "Sum Time", "Max Time");
-           moveRowToUpQueue(statsBuf_);
-        }
-        isHeadingDisplayed_ = TRUE;
-        step_ = FORMAT_AND_RETURN_HIVE_STATS_;
-      }
-      break;
-    case FORMAT_AND_RETURN_HIVE_STATS_:
-      {
-        short tableNameIndex = 2;
-        for (; currStatsItemEntry_ < maxHiveStatsItems_; currStatsItemEntry_++)
-        {
-          i = (short)currStatsItemEntry_;
-          if (hiveStatsItems_[i].error_code != 0)
-            continue;
-          switch (hiveStatsItems_[i].statsItem_id)
-          {
-          case SQLSTATS_TDB_ID:
-            str_sprintf(statsBuf_, "%-9Ld", hiveStatsItems_[i].int64_value);
-            break;
-          case SQLSTATS_DOP:
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10Ld", hiveStatsItems_[i].int64_value);
-            break;
-          case SQLSTATS_TABLE_ANSI_NAME:
-            hiveStatsItems_[i].str_value[hiveStatsItems_[i].str_ret_len] = '\0';
-            if (singleLineFormat_)
-               tableNameIndex = i;
-            else {
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "   %s", hiveStatsItems_[i].str_value);
-               if (moveRowToUpQueue(statsBuf_, strlen(statsBuf_), &rc) == -1)
-                  return rc;
-            }
-            break;
-          case SQLSTATS_EST_ROWS_ACCESSED:
-            FormatFloat(formattedFloatVal, intSize, valSize, hiveStatsItems_[i].double_value,
-			FALSE, TRUE);
-            if (singleLineFormat_)
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", formattedFloatVal);
-            else
-               str_sprintf(statsBuf_, "%-19s", formattedFloatVal);
-            break;
-          case SQLSTATS_EST_ROWS_USED:
-            FormatFloat(formattedFloatVal, intSize, valSize, hiveStatsItems_[i].double_value,
-			FALSE, TRUE);
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", formattedFloatVal);
-            if (! singleLineFormat_) {
-               if (moveRowToUpQueue(statsBuf_, strlen(statsBuf_), &rc) == -1)
-                  return rc;
-            }
-            break;
-          case SQLSTATS_ACT_ROWS_ACCESSED:
-            str_sprintf(Int64Val, "%Ld", hiveStatsItems_[i].int64_value);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            if (singleLineFormat_)
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
-            else
-               str_sprintf(statsBuf_, "%-19s", Int64Val);
-            break;          
-          case SQLSTATS_ACT_ROWS_USED:
-            str_sprintf(Int64Val, "%Ld", hiveStatsItems_[i].int64_value);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
-            break;
-          case SQLSTATS_HIVE_IOS:
-           str_sprintf(Int64Val, "%Ld", hiveStatsItems_[i].int64_value);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-13s", Int64Val);
-            break;
-          case SQLSTATS_HIVE_IO_BYTES:
-            str_sprintf(Int64Val, "%Ld", hiveStatsItems_[i].int64_value/1024/1024);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-13s", Int64Val);
-            break;
-          case SQLSTATS_HIVE_IO_ELAPSED_TIME:
-            str_sprintf(Int64Val, "%Ld", hiveStatsItems_[i].int64_value);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
-            break;
-          case SQLSTATS_HIVE_IO_MAX_TIME:
-            str_sprintf(Int64Val, "%Ld", hiveStatsItems_[i].int64_value);
-            intSize = str_len(Int64Val);
-            AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
-            break;
-          default:
-            break;
-          }
-        }
-        if (singleLineFormat_)
-           str_sprintf(&statsBuf_[strlen(statsBuf_)], " %s", hiveStatsItems_[2].str_value);
-        if (moveRowToUpQueue(statsBuf_, strlen(statsBuf_), &rc) == -1)
-          return rc;
-        step_ = GET_NEXT_STATS_DESC_ENTRY_;
-      }
-      break;
     case GET_BMO_STATS_ENTRY_:
       {
         if (bmoStatsItems_ == NULL)
         {
-          maxBMOStatsItems_ = 17;
+          maxBMOStatsItems_ = 19;
           bmoStatsItems_ = new (getGlobals()->getDefaultHeap()) 
                   SQLSTATS_ITEM[maxBMOStatsItems_];
           initSqlStatsItems(bmoStatsItems_, maxBMOStatsItems_, FALSE);
@@ -3124,20 +3047,22 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           bmoStatsItems_[2].statsItem_id = SQLSTATS_SCRATCH_OVERFLOW_MODE;
           bmoStatsItems_[3].statsItem_id = SQLSTATS_DOP;
           bmoStatsItems_[4].statsItem_id = SQLSTATS_TOPN;
-          bmoStatsItems_[5].statsItem_id = SQLSTATS_OPER_CPU_TIME;
-          bmoStatsItems_[6].statsItem_id = SQLSTATS_BMO_HEAP_USED;
-          bmoStatsItems_[7].statsItem_id = SQLSTATS_BMO_HEAP_ALLOC;
-          bmoStatsItems_[8].statsItem_id = SQLSTATS_BMO_HEAP_WM;
-          bmoStatsItems_[9].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_SIZE;
-          bmoStatsItems_[10].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_COUNT;
-          bmoStatsItems_[11].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
-          bmoStatsItems_[12].statsItem_id = SQLSTATS_SCRATCH_IO_SIZE;
-          bmoStatsItems_[13].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
-          bmoStatsItems_[14].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
-          bmoStatsItems_[15].statsItem_id = SQLSTATS_SCRATCH_IO_TIME;
-          bmoStatsItems_[16].statsItem_id = SQLSTATS_SCRATCH_IO_MAX_TIME;
-           
-          // maxBMOStatsItems_ is set to 17 
+          bmoStatsItems_[5].statsItem_id = SQLSTATS_BMO_PHASE;
+          bmoStatsItems_[6].statsItem_id = SQLSTATS_INTERIM_ROW_COUNT;
+          bmoStatsItems_[7].statsItem_id = SQLSTATS_OPER_CPU_TIME;
+          bmoStatsItems_[8].statsItem_id = SQLSTATS_BMO_HEAP_USED;
+          bmoStatsItems_[9].statsItem_id = SQLSTATS_BMO_HEAP_ALLOC;
+          bmoStatsItems_[10].statsItem_id = SQLSTATS_BMO_HEAP_WM;
+          bmoStatsItems_[11].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_SIZE;
+          bmoStatsItems_[12].statsItem_id = SQLSTATS_BMO_SPACE_BUFFER_COUNT;
+          bmoStatsItems_[13].statsItem_id = SQLSTATS_SCRATCH_FILE_COUNT;
+          bmoStatsItems_[14].statsItem_id = SQLSTATS_SCRATCH_IO_SIZE;
+          bmoStatsItems_[15].statsItem_id = SQLSTATS_SCRATCH_READ_COUNT;
+          bmoStatsItems_[16].statsItem_id = SQLSTATS_SCRATCH_WRITE_COUNT;
+          bmoStatsItems_[17].statsItem_id = SQLSTATS_SCRATCH_IO_TIME;
+          bmoStatsItems_[18].statsItem_id = SQLSTATS_SCRATCH_IO_MAX_TIME;
+                  
+          // maxBMOStatsItems_ is set to 19 
           // TDB_NAME
           bmoStatsItems_[1].str_value = new (getGlobals()->getDefaultHeap())
                       char[MAX_TDB_NAME_LEN+1];
@@ -3146,6 +3071,10 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           bmoStatsItems_[2].str_value = new (getGlobals()->getDefaultHeap())
                       char[13];
           bmoStatsItems_[2].str_max_len = 12;
+          // BMO_PHASE
+          bmoStatsItems_[5].str_value = new (getGlobals()->getDefaultHeap())
+                      char[12];
+          bmoStatsItems_[5].str_max_len = 11;
         }
         else
           initSqlStatsItems(bmoStatsItems_, maxBMOStatsItems_, TRUE);
@@ -3174,24 +3103,24 @@ short ExExeUtilGetRTSStatisticsTcb::work()
 	      return WORK_CALL_AGAIN;
        moveRowToUpQueue(" ");
        if (singleLineFormat()) {       
-          str_sprintf(statsBuf_, "%-5s%-19s%-19s%-10s%-9s%-20s%-24s%-19s%-19s%-20s%-20s%-12s%-11s%-19s%-19s%-20s%-20s",
-               "Id", "TDBName", "Mode", "DOP", "TopN", "CPUTime",
-                "BMOHeapUsed", "BMOHeapAllocated", "BMOHeapWM",
-                "BMOSpaceBufSz","BMOSpaceBufCnt", "ScrFileCnt", "ScrIOSize",
+          str_sprintf(statsBuf_, "%-5s%-20s%-5s%-10s%-10s%-12s%-20s%-20s%-20s%-20s%-20s%-20s%-20s%-10s%-10s%-20s%-20s%-20s%-20s",
+               "Id", "TDBName", "Mode", "DOP", "TopN", "BMOPhase", "InterimRowCount", "CPUTime",
+                "BMOHeapUsed", "BMOHeapAllocated", "BMOHeapWM", 
+                "BMOSpaceBufSz","BMOSpaceBufCnt", "FileCnt", "ScrIOSize",
                 "ScrIORead", "ScrIOWritten", "ScrIOTime", "ScrIOMaxTime");
           moveRowToUpQueue(statsBuf_);
        }
        else {
-          str_sprintf(statsBuf_, "%-5s%-19s%-19s%-10s%-9s%-20s",
-               "Id", "TDBName", "Mode", "DOP", "TopN", "CPUTime");
+          str_sprintf(statsBuf_, "%-5s%-20s%-20s%-10s%-10s%-20s%-20s%-20s",
+               "Id", "TDBName", "Mode", "DOP", "TopN", "BMOPhase", "InterimRowCount", "CPUTime");
           moveRowToUpQueue(statsBuf_);
         
-          str_sprintf(statsBuf_, "%-24s%-19s%-19s%-20s%-20s",
+          str_sprintf(statsBuf_, "%-25s%-20s%-20s%-20s%-20s",
                 "BMOHeapUsed", "BMOHeapAllocated", "BMOHeapWM",
                 "BMOSpaceBufSz","BMOSpaceBufCnt");
           moveRowToUpQueue(statsBuf_);
        
-          str_sprintf(statsBuf_, "%-11s%-13s%-19s%-19s%-20s%-20s",
+          str_sprintf(statsBuf_, "%-25s%-20s%-20s%-20s%-20s%-20s",
                 "ScrFileCnt", "ScrIOSize", "ScrIORead", "ScrIOWritten", "ScrIOTime", "ScrIOMaxTime");
           moveRowToUpQueue(statsBuf_);
         }
@@ -3201,6 +3130,7 @@ short ExExeUtilGetRTSStatisticsTcb::work()
       break;
     case FORMAT_AND_RETURN_BMO_STATS_:
       {
+        const char *ofMode;
         for (; currStatsItemEntry_ < maxBMOStatsItems_; currStatsItemEntry_++)
         {
           i = (short)currStatsItemEntry_;
@@ -3213,11 +3143,17 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             break;
           case SQLSTATS_TDB_NAME:
             bmoStatsItems_[i].str_value[bmoStatsItems_[i].str_ret_len] = '\0';
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", bmoStatsItems_[i].str_value);
+            if (singleLineFormat_) 
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], " %19s", bmoStatsItems_[i].str_value);
+            else 
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", bmoStatsItems_[i].str_value);
             break;
           case SQLSTATS_SCRATCH_OVERFLOW_MODE:
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", 
-                 ExBMOStats::getScratchOverflowMode((Int16) bmoStatsItems_[i].int64_value));
+            ofMode = ExBMOStats::getScratchOverflowMode((Int16) bmoStatsItems_[i].int64_value);
+            if (singleLineFormat_) 
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-5s", ofMode);
+            else
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", ofMode);
             break;
           case SQLSTATS_DOP:
             str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10Ld", bmoStatsItems_[i].int64_value);
@@ -3226,7 +3162,20 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-9s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10s", Int64Val);
+            break;
+          case SQLSTATS_BMO_PHASE:
+            bmoStatsItems_[i].str_value[bmoStatsItems_[i].str_ret_len] = '\0';
+            if (singleLineFormat_) 
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-12s", bmoStatsItems_[i].str_value);
+            else
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", bmoStatsItems_[i].str_value);
+            break;
+          case SQLSTATS_INTERIM_ROW_COUNT:
+            str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
+            intSize = str_len(Int64Val);
+            AddCommas(Int64Val,intSize); 
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_OPER_CPU_TIME:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
@@ -3243,16 +3192,16 @@ short ExExeUtilGetRTSStatisticsTcb::work()
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
             if (singleLineFormat_) 
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-24s", Int64Val);
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             else
-               str_sprintf(statsBuf_, "%-24s", Int64Val);
+               str_sprintf(statsBuf_, "%-25s", Int64Val);
             break;
           case SQLSTATS_BMO_HEAP_ALLOC:
           case SQLSTATS_BMO_HEAP_WM:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
@@ -3273,27 +3222,30 @@ short ExExeUtilGetRTSStatisticsTcb::work()
           case SQLSTATS_SCRATCH_FILE_COUNT:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
             if (singleLineFormat_) 
-               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-5s", Int64Val);
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10s", Int64Val);
             else
-               str_sprintf(statsBuf_, "%-5s", Int64Val);
+               str_sprintf(statsBuf_, "%-25s", Int64Val);
             break;
           case SQLSTATS_SCRATCH_IO_SIZE:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            if (singleLineFormat_) 
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-10s", Int64Val);
+            else
+               str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_SCRATCH_READ_COUNT:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_SCRATCH_WRITE_COUNT:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);
             intSize = str_len(Int64Val);
             AddCommas(Int64Val,intSize); 
-            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-19s", Int64Val);
+            str_sprintf(&statsBuf_[strlen(statsBuf_)], "%-20s", Int64Val);
             break;
           case SQLSTATS_SCRATCH_IO_TIME:
             str_sprintf(Int64Val, "%Ld", bmoStatsItems_[i].int64_value);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ExStats.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExStats.cpp b/core/sql/executor/ExStats.cpp
index 02ba58a..56a0a9d 100644
--- a/core/sql/executor/ExStats.cpp
+++ b/core/sql/executor/ExStats.cpp
@@ -75,6 +75,9 @@
 #include "Statement.h"
 #include "ComTdbRoot.h"
 #include "ComDistribution.h"
+#include "ex_hashj.h"
+#include "ex_sort.h"
+#include "ex_hash_grby.h"
 
 #include <unistd.h>
 #include <errno.h>
@@ -1543,11 +1546,13 @@ void ExFragRootOperStats::init(NABoolean resetDop)
   localCpuTime_ = 0;
   scratchOverflowMode_ = -1;
   scratchFileCount_ = 0;
-  scratchBufferBlockSize_ = 0;
-  scratchBufferBlockRead_ = 0;
-  scratchBufferBlockWritten_ = 0;
+  scratchIOSize_ = 0;
+  spaceBufferSize_ = 0;
+  spaceBufferCount_ = 0;
   scratchWriteCount_ = 0;
   scratchReadCount_ = 0;
+  scratchIOMaxTime_ = 0;
+  interimRowCount_ = 0;
   udrCpuTime_ = 0;
   topN_ = -1;
   waitTime_ = 0;
@@ -1716,18 +1721,26 @@ void ExFragRootOperStats::merge(ExFragRootOperStats* other)
   if (scratchOverflowMode_ == -1)
     scratchOverflowMode_ = other->scratchOverflowMode_;
   scratchFileCount_ += other->scratchFileCount_;
-
-  if (scratchBufferBlockSize_ == 0 &&
-     other->scratchBufferBlockSize_ > 0)
-     scratchBufferBlockSize_ = other->scratchBufferBlockSize_;
   Float32 mFactor = 1;
-  if(scratchBufferBlockSize_ > 0)
-    mFactor = (Float32)other->scratchBufferBlockSize_ / scratchBufferBlockSize_;
-  scratchBufferBlockRead_ += Int32 (other->scratchBufferBlockRead_ * mFactor);
-  scratchBufferBlockWritten_ += Int32 (other->scratchBufferBlockWritten_ * mFactor);
-
-  scratchReadCount_ += other->scratchReadCount_;
-  scratchWriteCount_ += other->scratchWriteCount_;
+  if (spaceBufferSize_ == 0 &&
+     other->spaceBufferSize_ > 0)
+     spaceBufferSize_ = other->spaceBufferSize_;
+  mFactor = 1;
+  if(spaceBufferSize_ > 0)
+    mFactor = (Float32)other->spaceBufferSize_ / spaceBufferSize_;
+  spaceBufferCount_ += Int32(other->spaceBufferCount_ * mFactor);
+  if (scratchIOSize_ == 0 &&
+     other->scratchIOSize_ > 0)
+     scratchIOSize_ = other->scratchIOSize_;
+  mFactor = 1;
+  if(scratchIOSize_ > 0)
+    mFactor = (Float32)other->scratchIOSize_ / scratchIOSize_;
+
+  scratchReadCount_ += Int32(other->scratchReadCount_ * mFactor);
+  scratchWriteCount_ += Int32(other->scratchWriteCount_ * mFactor);
+  if (other->scratchIOMaxTime_ > scratchIOMaxTime_)
+     scratchIOMaxTime_ = other->scratchIOMaxTime_;
+  interimRowCount_ += other->interimRowCount_;
   udrCpuTime_ += other->udrCpuTime_;
   if(topN_ == -1 && other->topN_ > 0)
     topN_ = other->topN_;
@@ -1751,18 +1764,24 @@ void ExFragRootOperStats::merge(ExBMOStats *other)
 {
   scratchFileCount_ += other->scratchFileCount_;
   scratchOverflowMode_ = other->scratchOverflowMode_;
-  
-  if (scratchBufferBlockSize_ == 0 &&
-     other->scratchBufferBlockSize_ > 0)
-     scratchBufferBlockSize_ = other->scratchBufferBlockSize_;
   Float32 mFactor = 1;
-  if(scratchBufferBlockSize_ > 0)
-    mFactor = (Float32)other->scratchBufferBlockSize_ / scratchBufferBlockSize_;
-  scratchBufferBlockRead_ += Int32 (other->scratchBufferBlockRead_ * mFactor);
-  scratchBufferBlockWritten_ += Int32 (other->scratchBufferBlockWritten_ * mFactor);
-
-  scratchReadCount_ += other->scratchReadCount_;
-  scratchWriteCount_ += other->scratchWriteCount_;
+  if (spaceBufferSize_ == 0 &&
+     other->spaceBufferSize_ > 0)
+     spaceBufferSize_ = other->spaceBufferSize_;
+  mFactor = 1;
+  if(spaceBufferSize_ > 0)
+    mFactor = (Float32)other->spaceBufferSize_ / spaceBufferSize_;
+  spaceBufferCount_ += Int32(other->spaceBufferCount_ * mFactor);
+  if (scratchIOSize_ == 0 &&
+     other->scratchIOSize_ > 0)
+     scratchIOSize_ = other->scratchIOSize_;
+  mFactor = 1;
+  if(scratchIOSize_ > 0)
+    mFactor = (Float32)other->scratchIOSize_ / scratchIOSize_;
+  scratchReadCount_ += Int32 (other->scratchReadCount_ * mFactor);
+  scratchWriteCount_ += Int32 (other->scratchWriteCount_ * mFactor);
+  scratchIOMaxTime_ += other->scratchIOMaxTime_;
+  interimRowCount_ += other->interimRowCount_;
   if(topN_ == -1 && other->topN_ > 0)
     topN_ = other->topN_;
 }
@@ -1895,8 +1914,8 @@ void ExFragRootOperStats::getVariableStatsInfo(char * dataBuffer,
 		"Newprocess: %u NewprocessTime: %Ld reqMsgCnt: %Ld "
 		"regMsgBytes: %Ld replyMsgCnt: %Ld replyMsgBytes: %Ld "
 		"PMemUsed: %Ld scrOverFlowMode: %d sortTopN: %Ld"
-		"scrFileCount: %d scrBufferBlockSize: %d scrBuffferRead: %Ld scrBufferWritten: %Ld "
-		"scrWriteCount:%Ld scrReadCount: %Ld udrCpuTime: %Ld "
+		"scrFileCount: %d bmoSpaceBufferSize: %d bmoSpaceBufferCount: %Ld scrIOSize: %d " 
+		"scrWriteCount:%Ld scrReadCount: %Ld scrIOMaxTime: %Ld bmoInterimRowCount: %Ld udrCpuTime: %Ld "
 		"maxWaitTime: %Ld avgWaitTime: %Ld "
 		"hdfsAccess: %Ld ",
 		cpuTime_,
@@ -1918,11 +1937,13 @@ void ExFragRootOperStats::getVariableStatsInfo(char * dataBuffer,
 		scratchOverflowMode_,
 		topN_,
 		scratchFileCount_,
-		scratchBufferBlockSize_,
-		scratchBufferBlockRead_,
-		scratchBufferBlockWritten_,
+                spaceBufferSize_,
+                spaceBufferCount_,
+		scratchIOSize_,
 		scratchWriteCount_,
 		scratchReadCount_,
+                scratchIOMaxTime_,
+                interimRowCount_,
 		udrCpuTime_,
 		maxWaitTime_,
 		getAvgWaitTime(),
@@ -2008,14 +2029,14 @@ Lng32 ExFragRootOperStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
     case SQLSTATS_TOPN:
       sqlStats_item->int64_value = topN_;
       break;
-    case SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE:
-      sqlStats_item->int64_value = scratchBufferBlockSize_;
+    case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
+      sqlStats_item->int64_value = spaceBufferSize_;
       break;
-    case SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ:
-      sqlStats_item->int64_value = scratchBufferBlockRead_;
+    case SQLSTATS_BMO_SPACE_BUFFER_COUNT:
+      sqlStats_item->int64_value = spaceBufferCount_;
       break;
-    case SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN:
-      sqlStats_item->int64_value = scratchBufferBlockWritten_;
+    case SQLSTATS_SCRATCH_IO_SIZE:
+      sqlStats_item->int64_value = scratchIOSize_;
       break;
     case SQLSTATS_SCRATCH_READ_COUNT:
       sqlStats_item->int64_value = scratchReadCount_;
@@ -2023,6 +2044,12 @@ Lng32 ExFragRootOperStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
     case SQLSTATS_SCRATCH_WRITE_COUNT:
       sqlStats_item->int64_value = scratchWriteCount_;
       break;
+    case SQLSTATS_SCRATCH_IO_MAX_TIME:
+      sqlStats_item->int64_value = scratchIOMaxTime_;
+      break;
+    case SQLSTATS_INTERIM_ROW_COUNT:
+      sqlStats_item->int64_value = interimRowCount_;
+      break;
     case SQLSTATS_UDR_CPU_BUSY_TIME:
       sqlStats_item->int64_value = udrCpuTime_;
       break;
@@ -4585,19 +4612,8 @@ UInt32 ExMeasStats::packedLength()
   else
   {
     size = ExMeasBaseStats::packedLength();
-    if (NOT statsInDp2())
-    {
-      alignSizeForNextObj(size);
-      size += sizeof(ExMeasStats)-sizeof(ExMeasBaseStats);
-    }
-    else
-    {
-      size += sizeof(spaceUsage_);
-      size += sizeof(spaceAlloc_);
-      size += sizeof(heapUsage_);
-      size += sizeof(heapAlloc_);
-      size += sizeof(heapWM_);
-    }
+    alignSizeForNextObj(size);
+    size += sizeof(ExMeasStats)-sizeof(ExMeasBaseStats);
   }
   return size;
 }
@@ -4648,27 +4664,12 @@ UInt32 ExMeasStats::pack(char * buffer)
   else
   {
     size = ExMeasBaseStats::pack(buffer);
-    if (NOT statsInDp2())
-    {
-      alignSizeForNextObj(size);
-      buffer += size;
-      srcLen = sizeof(ExMeasStats)-sizeof(ExMeasBaseStats);
-      char * srcPtr = (char *)this+sizeof(ExMeasBaseStats);
-      memcpy(buffer, (void *)srcPtr, srcLen);
-      size += srcLen;
-    }
-    else
-    {
-      buffer += size;
-      if (getVersion() >= _STATS_RTS_VERSION_R22)
-      {
-        size += packIntoBuffer(buffer, spaceUsage_);
-        size += packIntoBuffer(buffer, spaceAlloc_);
-        size += packIntoBuffer(buffer, heapUsage_);
-        size += packIntoBuffer(buffer, heapAlloc_);
-        size += packIntoBuffer(buffer, heapWM_);
-      }
-    }
+    alignSizeForNextObj(size);
+    buffer += size;
+    srcLen = sizeof(ExMeasStats)-sizeof(ExMeasBaseStats);
+    char * srcPtr = (char *)this+sizeof(ExMeasBaseStats);
+    memcpy(buffer, (void *)srcPtr, srcLen);
+    size += srcLen;
   }
   return size;
 }
@@ -4714,15 +4715,13 @@ void ExMeasStats::unpack(const char* &buffer)
   }
   else
   {
-    if (NOT statsInDp2())
-    {
-      alignBufferForNextObj(buffer); 
-      UInt32 srcLen = sizeof(ExMeasStats)-sizeof(ExMeasBaseStats);
-      char * srcPtr = (char *)this+sizeof(ExMeasBaseStats);
-      memcpy((void *)srcPtr, buffer, srcLen);
-      buffer += srcLen;
-      if (statsInEsp())
-      {
+     alignBufferForNextObj(buffer); 
+     UInt32 srcLen = sizeof(ExMeasStats)-sizeof(ExMeasBaseStats);
+     char * srcPtr = (char *)this+sizeof(ExMeasBaseStats);
+     memcpy((void *)srcPtr, buffer, srcLen);
+     buffer += srcLen;
+     if (statsInEsp())
+     {
         espSpaceUsage_ += spaceUsage_;
         espSpaceAlloc_ += spaceAlloc_;
         espHeapUsage_  += heapUsage_;
@@ -4735,7 +4734,6 @@ void ExMeasStats::unpack(const char* &buffer)
         heapAlloc_ = 0;
         heapWM_ = 0;
         cpuTime_ = 0;
-      }
     }
   }
 }
@@ -4771,9 +4769,11 @@ void ExMeasStats::init(NABoolean resetDop)
   localCpuTime_ = 0;
   scratchOverflowMode_ = -1;
   scratchFileCount_ = 0;
-  scratchBufferBlockSize_ = 0;
-  scratchBufferBlockRead_ = 0;
-  scratchBufferBlockWritten_ = 0;
+  spaceBufferSize_ = 0;
+  spaceBufferCount_ = 0;
+  scratchIOSize_ = 0;
+  interimRowCount_ = 0;
+  scratchIOMaxTime_ = 0;
   scratchWriteCount_ = 0;
   scratchReadCount_ = 0;
   udrCpuTime_ = 0;
@@ -4818,17 +4818,20 @@ void ExMeasStats::merge(ExBMOStats *other)
 {
   scratchFileCount_ += other->scratchFileCount_;
   scratchOverflowMode_ = other->scratchOverflowMode_;
-  if (scratchBufferBlockSize_ == 0 &&
-     other->scratchBufferBlockSize_ > 0)
-     scratchBufferBlockSize_ = other->scratchBufferBlockSize_;
+  if (spaceBufferSize_ == 0 &&
+     other->spaceBufferSize_ > 0)
+     spaceBufferSize_ = other->spaceBufferSize_;
   Float32 mFactor = 1;
-  if(scratchBufferBlockSize_ > 0)
-    mFactor = (Float32)other->scratchBufferBlockSize_ / scratchBufferBlockSize_;
-  scratchBufferBlockRead_ += Int32 (other->scratchBufferBlockRead_ * mFactor);
-  scratchBufferBlockWritten_ += Int32 (other->scratchBufferBlockWritten_ * mFactor);
-
-  scratchReadCount_ += other->scratchReadCount_;
-  scratchWriteCount_ += other->scratchWriteCount_;
+  if(spaceBufferSize_ > 0)
+    mFactor = (Float32)other->spaceBufferSize_ / spaceBufferSize_;
+  spaceBufferCount_ += Int32 (other->spaceBufferCount_ * mFactor);
+  mFactor = 1;
+  if(scratchIOSize_ > 0)
+    mFactor = (Float32)other->scratchIOSize_ / scratchIOSize_;
+  scratchReadCount_ += (other->scratchReadCount_ * mFactor);
+  scratchWriteCount_ += (other->scratchWriteCount_ * mFactor);
+  scratchIOMaxTime_ += other->scratchIOMaxTime_;   
+  interimRowCount_ += other->interimRowCount_;
   if (topN_ == -1 && other->topN_ > 0)
       topN_ = other->topN_;
 }
@@ -4879,17 +4882,21 @@ void ExMeasStats::merge(ExMeasStats* other)
   replyMsgBytes_    += other -> replyMsgBytes_;
   scratchFileCount_ += other->scratchFileCount_;
 
-  if (scratchBufferBlockSize_ == 0 &&
-     other->scratchBufferBlockSize_ > 0)
-     scratchBufferBlockSize_ = other->scratchBufferBlockSize_;
+  if (spaceBufferSize_ == 0 &&
+     other->spaceBufferSize_ > 0)
+     spaceBufferSize_ = other->spaceBufferSize_;
   Float32 mFactor = 1;
-  if(scratchBufferBlockSize_ > 0)
-    mFactor = (Float32)other->scratchBufferBlockSize_ / scratchBufferBlockSize_;
-  scratchBufferBlockRead_ += Int32 (other->scratchBufferBlockRead_ * mFactor);
-  scratchBufferBlockWritten_ += Int32 (other->scratchBufferBlockWritten_ * mFactor);
-
-  scratchReadCount_ += other->scratchReadCount_;
-  scratchWriteCount_ += other->scratchWriteCount_;
+  if(spaceBufferSize_ > 0)
+    mFactor = (Float32)other->spaceBufferSize_ / spaceBufferSize_;
+  spaceBufferCount_ += Int32 (other->spaceBufferCount_ * mFactor);
+  mFactor = 1;
+  if(scratchIOSize_ > 0)
+    mFactor = (Float32)other->scratchIOSize_ / scratchIOSize_;
+  scratchReadCount_ += (other->scratchReadCount_ * mFactor);
+  scratchWriteCount_ += (other->scratchWriteCount_ * mFactor);
+  if (other->scratchIOMaxTime_ > scratchIOMaxTime_)
+     scratchIOMaxTime_ = other->scratchIOMaxTime_;   
+  interimRowCount_ += other->interimRowCount_;
   udrCpuTime_ += other->udrCpuTime_;
   if (topN_ == -1 && other->topN_ > 0)
       topN_ = other->topN_;
@@ -4995,11 +5002,13 @@ void ExMeasStats::copyContents(ExMeasStats *other)
   replyMsgCnt_  = other->replyMsgCnt_;
   replyMsgBytes_  = other->replyMsgBytes_;
   scratchFileCount_ = other->scratchFileCount_;
-  scratchBufferBlockSize_ = other->scratchBufferBlockSize_;
-  scratchBufferBlockRead_ = other->scratchBufferBlockRead_;
-  scratchBufferBlockWritten_ = other->scratchBufferBlockWritten_;
+  spaceBufferSize_ = other->spaceBufferSize_;
+  spaceBufferCount_ = other->spaceBufferCount_;
+  scratchIOSize_ = other->scratchIOSize_;
   scratchReadCount_ = other->scratchReadCount_;
   scratchWriteCount_ = other->scratchWriteCount_;
+  scratchIOMaxTime_ = other->scratchIOMaxTime_;
+  interimRowCount_ = interimRowCount_;
   udrCpuTime_ = other->udrCpuTime_;
   topN_ = other->topN_;
   }
@@ -5064,8 +5073,8 @@ void ExMeasStats::getVariableStatsInfo(char * dataBuffer, char * datalen,
     "SpaceTotal: %d  SpaceUsed: %d HeapTotal: %d HeapUsed: %d HeapWM: %u CpuTime: %Ld "
     "reqMsgCnt: %Ld reqMsgBytes: %Ld replyMsgCnt: %Ld "
     "replyMsgBytes: %Ld scrOverflowMode: %d sortTopN: %Ld"
-    "scrFileCount: %d scrBufferBlockSize: %d scrBufferRead: %Ld scrBufferWritten: %Ld "
-    "scrWriteCount: %Ld scrReadCount: %Ld udrCpuTime: %Ld",
+    "scrFileCount: %d bmoSpaceBufferSize: %d bmoSpaceBufferCount: %Ld scrIoSize: %d "
+    "scrWriteCount: %Ld scrReadCount: %Ld scrIOMaxTime: %Ld interimRowCount: %Ld udrCpuTime: %Ld ",
 	      statType(),
               getNewprocess(),
 	      getNewprocessTime(),
@@ -5085,11 +5094,13 @@ void ExMeasStats::getVariableStatsInfo(char * dataBuffer, char * datalen,
               scratchOverflowMode_,
               topN_,
               scratchFileCount_,
-              scratchBufferBlockSize_,
-              scratchBufferBlockRead_,
-              scratchBufferBlockWritten_,
+              spaceBufferSize_,
+              spaceBufferCount_,
+              scratchIOSize_,
               scratchWriteCount_,
               scratchReadCount_,
+              scratchIOMaxTime_,
+              interimRowCount_,
               udrCpuTime_
               );
   }
@@ -5178,14 +5189,11 @@ Lng32 ExMeasStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
   case SQLSTATS_SCRATCH_OVERFLOW_MODE:
     sqlStats_item->int64_value = scratchOverflowMode_;
     break;
-  case SQLSTATS_SCRATCH_BUFFER_BLOCK_SIZE:
-    sqlStats_item->int64_value = scratchBufferBlockSize_;
-    break;
-  case SQLSTATS_SCRATCH_BUFFER_BLOCKS_READ:
-    sqlStats_item->int64_value = scratchBufferBlockRead_;
+  case SQLSTATS_BMO_SPACE_BUFFER_SIZE:
+    sqlStats_item->int64_value = spaceBufferSize_;
     break;
-  case SQLSTATS_SCRATCH_BUFFER_BLOCKS_WRITTEN:
-    sqlStats_item->int64_value = scratchBufferBlockWritten_;
+  case SQLSTATS_BMO_SPACE_BUFFER_COUNT:
+    sqlStats_item->int64_value = spaceBufferCount_;
     break;
   case SQLSTATS_SCRATCH_READ_COUNT:
     sqlStats_item->int64_value = scratchReadCount_;
@@ -5193,6 +5201,18 @@ Lng32 ExMeasStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
   case SQLSTATS_SCRATCH_WRITE_COUNT:
     sqlStats_item->int64_value = scratchWriteCount_;
     break;
+  case SQLSTATS_SCRATCH_IO_SIZE:
+    sqlStats_item->int64_value = scratchIOSize_;
+    break;
+  case SQLSTATS_SCRATCH_IO_MAX_TIME:
+    sqlStats_item->int64_value = scratchIOMaxTime_;
+    break;
+  case SQLSTATS_INTERIM_ROW_COUNT:
+    sqlStats_item->int64_value = interimRowCount_;
+    break;
+  case SQLSTATS_TOPN:
+    sqlStats_item->int64_value = topN_;
+    break;
   case SQLSTATS_UDR_CPU_BUSY_TIME:
     sqlStats_item->int64_value = udrCpuTime_;
     break;
@@ -6961,7 +6981,7 @@ const char *ExStatisticsArea::getStatsTypeText(short statsType)
   case SQLCLI_PROGRESS_STATS:
     return "PROGRESS_STATS";
   default:
-    return "UNKNOW";
+    return "UNKNOWN";
   }
 }
 
@@ -10475,6 +10495,8 @@ void ExBMOStats::init(NABoolean resetDop)
   topN_ = -1;
   timer_.reset();
   scratchIOMaxTime_ = 0;
+  phase_ = 0;
+  interimRowCount_ = 0;
 }
 
 UInt32 ExBMOStats::packedLength()
@@ -10566,12 +10588,14 @@ void ExBMOStats::getVariableStatsInfo(char * dataBuffer,
   char *buf = dataBuffer;
   str_sprintf (
        buf,
-       "statsRowType: %d explainTdbId: %d bmoHeapUsed: %d bmoHeapTotal: %d bmoHeapWM: %d "
+       "statsRowType: %d explainTdbId: %d bmoPhase: %s bmoIntCount: %Ld estMemory: %0.2f bmoHeapUsed: %d bmoHeapTotal: %d bmoHeapWM: %d "
        "bmoSpaceBufferSize: %d bmoSpaceBufferCount: %d "
        "scrOverFlowMode: %d scrFileCount: %d scrBufferBlockSize: %d scrBuffferRead: %d scrBufferWritten: %d "
        "scrWriteCount: %Ld scrReadCount: %Ld topN: %Ld scrIOSize: %d scrIOTime: %Ld scrIOMaxTime: %Ld ",
         statType(),
         getExplainNodeId(),
+        getBmoPhaseStr(),
+        interimRowCount_,
         bmoHeapUsage_,
         bmoHeapAlloc_,
         bmoHeapWM_,
@@ -10613,17 +10637,34 @@ void ExBMOStats::merge(ExBMOStats* other)
   if (other->scratchIOSize_ != -1)
     scratchIOSize_ = other->scratchIOSize_;
   if (other->topN_ != -1)
-    topN_ = other->topN_;
+     topN_ = other->topN_;
+  if (other->phase_ > phase_)
+     phase_ = other->phase_;
   scratchOverflowMode_ = other->scratchOverflowMode_;
   scratchFileCount_ += other->scratchFileCount_;
   scratchBufferBlockRead_ += other->scratchBufferBlockRead_;
   scratchBufferBlockWritten_ += other->scratchBufferBlockWritten_;
   scratchReadCount_ += other->scratchReadCount_;
   scratchWriteCount_ += other->scratchWriteCount_;
+  interimRowCount_ += other->interimRowCount_;
   if (other->scratchIOMaxTime_ > scratchIOMaxTime_)
      scratchIOMaxTime_ = other->scratchIOMaxTime_;
 }
 
+const char *ExBMOStats::getBmoPhaseStr()
+{
+  ComTdb::ex_node_type tdbType = getTdbType();
+  
+  if (tdbType == ComTdb::ex_HASHJ)
+     return ex_hashj_tcb::HashJoinPhaseStr[phase_];
+  else if (tdbType == ComTdb::ex_SORT)
+    return ExSortTcb::SortPhaseStr[phase_];
+  else if (tdbType == ComTdb::ex_HASH_GRBY)
+     return ex_hash_grby_tcb::HashGrbyPhaseStr[phase_];
+  else
+    return "UNKNOWN";  
+}
+
 Lng32 ExBMOStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
 {
   sqlStats_item->error_code = 0;
@@ -10680,6 +10721,23 @@ Lng32 ExBMOStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
   case SQLSTATS_SCRATCH_IO_MAX_TIME:
     sqlStats_item->int64_value = scratchIOMaxTime_;
     break;
+  case SQLSTATS_INTERIM_ROW_COUNT:
+    sqlStats_item->int64_value = interimRowCount_;
+    break;
+  case SQLSTATS_BMO_PHASE:
+    if (sqlStats_item->str_value != NULL)
+    {
+       const char *bmoPhase = getBmoPhaseStr();
+       len = strlen(bmoPhase);
+       if (len > sqlStats_item->str_max_len)
+          sqlStats_item->error_code = EXE_ERROR_IN_STAT_ITEM;
+       else
+          str_cpy(sqlStats_item->str_value, bmoPhase, len);
+       sqlStats_item->str_ret_len = len;
+    }
+    else
+       sqlStats_item->error_code = EXE_ERROR_IN_STAT_ITEM;
+    break;
   case SQLSTATS_DETAIL:
    if (sqlStats_item->str_value != NULL)
     {
@@ -10694,6 +10752,8 @@ Lng32 ExBMOStats::getStatsItem(SQLSTATS_ITEM* sqlStats_item)
         str_cpy(sqlStats_item->str_value, tmpBuf, len);
       sqlStats_item->str_ret_len = len;
     }
+    else
+       sqlStats_item->error_code = EXE_ERROR_IN_STAT_ITEM;
     break;
   default:
     ExOperStats::getStatsItem(sqlStats_item);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ExStats.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExStats.h b/core/sql/executor/ExStats.h
index a3fbe15..280e924 100644
--- a/core/sql/executor/ExStats.h
+++ b/core/sql/executor/ExStats.h
@@ -1207,7 +1207,11 @@ public:
   static const char *getScratchOverflowMode(Int16 overflowMode);
   ExTimeStats &getScratchIOTimer() { return timer_; }
   inline void setScratchIOSize(Int64 size) { scratchIOSize_ = size; }
-
+  const char *getBmoPhaseStr();
+  inline void setBmoPhase(Int16 phase) { phase_ = phase; }
+  inline Int16 getBmoPhase() { return phase_; }
+  void resetInterimRowCount() { interimRowCount_ = 0;}
+  void incInterimRowCount() { interimRowCount_++; }
 private:
   ExTimeStats timer_;
   Int32 bmoHeapAlloc_;
@@ -1225,6 +1229,8 @@ private:
   Int64 scratchIOMaxTime_;
   Int16 scratchOverflowMode_;   // 0 - disk 1 - SSD
   Int32 topN_;                 // TOPN value
+  Int64 interimRowCount_;
+  Int16 phase_;
 };
 
 
@@ -1453,11 +1459,13 @@ private:
   char *queryId_;
   Lng32 queryIdLen_;
   Int32 scratchFileCount_;
-  Int32 scratchBufferBlockSize_;
-  Int64 scratchBufferBlockRead_;
-  Int64 scratchBufferBlockWritten_;
+  Int32 spaceBufferSize_;
+  Int64 spaceBufferCount_;
+  Int32 scratchIOSize_;
   Int64 scratchReadCount_;
   Int64 scratchWriteCount_;
+  Int64 interimRowCount_;
+  Int64 scratchIOMaxTime_;
   Int64 udrCpuTime_;
   Int64 topN_;
   // process id of this fragment instance (to correlate it with MEASURE data)
@@ -2831,13 +2839,15 @@ private:
   Int64 localCpuTime_;
   Int16 scratchOverflowMode_;
   Int32 scratchFileCount_;
-  Int32 scratchBufferBlockSize_;
-  Int64 scratchBufferBlockRead_;
-  Int64 scratchBufferBlockWritten_;
+  Int32 spaceBufferSize_;
+  Int64 spaceBufferCount_;
   Int64 scratchReadCount_;
   Int64 scratchWriteCount_;
   Int64 udrCpuTime_;
-  Int64 topN_;
+  Int32 topN_;
+  Int32 scratchIOSize_;
+  Int64 interimRowCount_;
+  Int64 scratchIOMaxTime_;
 };
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_hash_grby.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_hash_grby.cpp b/core/sql/executor/ex_hash_grby.cpp
index 139e411..325c169 100644
--- a/core/sql/executor/ex_hash_grby.cpp
+++ b/core/sql/executor/ex_hash_grby.cpp
@@ -63,6 +63,15 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
+// In the reverse order of ex_hash_grbytcb::HashGrbyPhase
+// Limit to 11 characters
+const char *ex_hash_grby_tcb::HashGrbyPhaseStr[] = {
+    "PHASE_END",
+    "READ_SPILL",
+    "RETURN_ROWS",
+    "READ_ROWS"
+}; 
+
 NABoolean ex_hash_grby_tcb::needStatsEntry()
 {
   ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();
@@ -77,7 +86,9 @@ ExOperStats * ex_hash_grby_tcb::doAllocateStatsEntry(CollHeap *heap,
                                                      ComTdb *tdb)
 {
   ExBMOStats *stat;
-
+  ComTdbHashGrby *comTdbHashGrby = (ComTdbHashGrby *)tdb;
+  if (comTdbHashGrby->isNonBMOPartialGroupBy()) 
+     return ex_tcb::doAllocateStatsEntry(heap, tdb); 
   ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();
   if (statsType == ComTdb::OPERATOR_STATS)
     stat =  new (heap) ExBMOStats(heap, this, tdb);
@@ -452,6 +463,8 @@ short ex_hash_grby_tcb::work() {
             hasFreeTupp_ = TRUE;
     	};
       };
+      if (bmoStats_)
+         bmoStats_->setBmoPhase(PHASE_END-HGB_READ_PHASE);
 
       // now read the next row from the child queue
       workReadChild();
@@ -488,6 +501,9 @@ short ex_hash_grby_tcb::work() {
     } break;
 
     case HASH_GRBY_READ_BUFFER: {
+       if (bmoStats_ && (bmoStats_->getBmoPhase() == (PHASE_END-HGB_READ_PHASE)))
+         bmoStats_->setBmoPhase(PHASE_END-HGB_READ_SPILL_PHASE);
+
       workReadBuffer();
       if (state_ == HASH_GRBY_READ_BUFFER)
 	// I/O is not done yet
@@ -537,6 +553,9 @@ short ex_hash_grby_tcb::work() {
 	  else
 	    hasFreeTupp_ = TRUE;
 	};
+  
+       if (bmoStats_ && (bmoStats_->getBmoPhase() == (PHASE_END-HGB_READ_PHASE)))
+         bmoStats_->setBmoPhase(PHASE_END-HGB_RETURN_PHASE);
 	
 	// now we are ready to return a row
 	ULng32 retCode = workReturnRows(tryToDefrag);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_hash_grby.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_hash_grby.h b/core/sql/executor/ex_hash_grby.h
index 6d80463..5c06566 100644
--- a/core/sql/executor/ex_hash_grby.h
+++ b/core/sql/executor/ex_hash_grby.h
@@ -140,6 +140,16 @@ class ex_hash_grby_tcb : public ex_tcb {
     HASH_GRBY_CANCELED
   };
 
+  // the phase of the hash groupby algorithm
+  // Change ex_hash_grby_tcb::HashGrbyPhaseStr when you add new value to this enum
+  // New phase enum value should be added before PHASE_END
+  enum HashGrbyPhase {
+    HGB_READ_PHASE,
+    HGB_RETURN_PHASE,
+    HGB_READ_SPILL_PHASE,
+    PHASE_END
+  };
+
   Space * space_;
   CollHeap * heap_;
 #ifndef __EID
@@ -302,6 +312,7 @@ NA_EIDPROC
   void resetClusterAndReadFromChild(); // Tmobile.
 
 public:
+  static const char *HashGrbyPhaseStr[];
 
 NA_EIDPROC
   ex_hash_grby_tcb(const ex_hash_grby_tdb & hash_grby_tdb,    


[2/7] incubator-trafodion git commit: [TRAFODION-2420] RMS enhancements

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/regress/core/EXPECTEDRTS
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTEDRTS b/core/sql/regress/core/EXPECTEDRTS
index bff1d37..1ea5583 100755
--- a/core/sql/regress/core/EXPECTEDRTS
+++ b/core/sql/regress/core/EXPECTEDRTS
@@ -56,10 +56,10 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 --- SQL operation complete.
 >>log LOGRTS;
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -94,11 +94,11 @@ Stats Collection Type    ACCUMULATED_STATS
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_272_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_279_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -129,11 +129,11 @@ Last Suspend Time        -1
 Stats Collection Type    ACCUMULATED_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_272_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_279_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -166,10 +166,10 @@ Stats Collection Type    ACCUMULATED_STATS
 --- SQL operation complete.
 >>log;
 >>display statistics for qid current;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -201,10 +201,10 @@ Stats Collection Type    ACCUMULATED_STATS
 
 --- SQL operation complete.
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -240,24 +240,24 @@ Stats Collection Type    ACCUMULATED_STATS
 D          
 -----------
 
+         12
+         11
          21
          22
-         11
-         12
 
 --- 4 row(s) selected.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_272_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
-Execute Start Time       2017/04/06 23:05:26.507000
-Execute End Time         2017/04/06 23:05:30.219438
-Execute Elapsed Time                 0:00:03.712438
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_279_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
+Execute Start Time       2017/05/07 05:40:29.596727
+Execute End Time         2017/05/07 05:40:34.141843
+Execute Elapsed Time                 0:00:04.545116
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -275,7 +275,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:30.217591
+First Row Returned Time  2017/05/07 05:40:34.139345
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -287,37 +287,40 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           765,673
-SQL Process Busy Time    3,750,747
+SE IO MAX Time           725,870
+SQL Process Busy Time    5,717,075
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
-SQL Heap Allocated       10,471                    KB
+SQL Heap Allocated       10,472                    KB
 SQL Heap Used            80                        KB
 SQL Heap WM              67                        KB
 Processes Created        2
-Process Create Time      142,012
+Process Create Time      150,942
 Request Message Count    26
-Request Message Bytes    39,392
+Request Message Bytes    39,808
 Reply Message Count      15
-Reply Message Bytes      38,760
+Reply Message Bytes      38,840
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_272_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
-Execute Start Time       2017/04/06 23:05:26.507000
-Execute End Time         2017/04/06 23:05:30.219438
-Execute Elapsed Time                 0:00:03.712438
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_279_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
+Execute Start Time       2017/05/07 05:40:29.596727
+Execute End Time         2017/05/07 05:40:34.141843
+Execute Elapsed Time                 0:00:04.545116
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -335,7 +338,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:30.217591
+First Row Returned Time  2017/05/07 05:40:34.139345
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -347,38 +350,41 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           765,673
-SQL Process Busy Time    3,750,747
+SE IO MAX Time           725,870
+SQL Process Busy Time    5,717,075
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
-SQL Heap Allocated       10,471                    KB
+SQL Heap Allocated       10,472                    KB
 SQL Heap Used            80                        KB
 SQL Heap WM              67                        KB
 Processes Created        2
-Process Create Time      142,012
+Process Create Time      150,942
 Request Message Count    26
-Request Message Bytes    39,392
+Request Message Bytes    39,808
 Reply Message Count      15
-Reply Message Bytes      38,760
+Reply Message Bytes      38,840
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>log;
 >>display statistics for qid current;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
-Execute Start Time       2017/04/06 23:05:26.507000
-Execute End Time         2017/04/06 23:05:30.219438
-Execute Elapsed Time                 0:00:03.712438
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
+Execute Start Time       2017/05/07 05:40:29.596727
+Execute End Time         2017/05/07 05:40:34.141843
+Execute Elapsed Time                 0:00:04.545116
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -396,7 +402,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:30.217591
+First Row Returned Time  2017/05/07 05:40:34.139345
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -408,37 +414,40 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           765,673
-SQL Process Busy Time    3,750,747
+SE IO MAX Time           725,870
+SQL Process Busy Time    5,717,075
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
-SQL Heap Allocated       10,471                    KB
+SQL Heap Allocated       10,472                    KB
 SQL Heap Used            80                        KB
 SQL Heap WM              67                        KB
 Processes Created        2
-Process Create Time      142,012
+Process Create Time      150,942
 Request Message Count    26
-Request Message Bytes    39,392
+Request Message Bytes    39,808
 Reply Message Count      15
-Reply Message Bytes      38,760
+Reply Message Bytes      38,840
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_272_S1
-Compile Start Time       2017/04/06 23:05:20.156375
-Compile End Time         2017/04/06 23:05:20.204717
-Compile Elapsed Time                 0:00:00.048342
-Execute Start Time       2017/04/06 23:05:26.507000
-Execute End Time         2017/04/06 23:05:30.219438
-Execute Elapsed Time                 0:00:03.712438
+Qid                      MXID11000004343212360895605883001000000000206U3333300_279_S1
+Compile Start Time       2017/05/07 05:40:25.200093
+Compile End Time         2017/05/07 05:40:25.230566
+Compile Elapsed Time                 0:00:00.030473
+Execute Start Time       2017/05/07 05:40:29.596727
+Execute End Time         2017/05/07 05:40:34.141843
+Execute Elapsed Time                 0:00:04.545116
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -456,7 +465,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:30.217591
+First Row Returned Time  2017/05/07 05:40:34.139345
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -468,27 +477,30 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           765,673
-SQL Process Busy Time    3,750,747
+SE IO MAX Time           725,870
+SQL Process Busy Time    5,717,075
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
-SQL Heap Allocated       10,471                    KB
+SQL Heap Allocated       10,472                    KB
 SQL Heap Used            80                        KB
 SQL Heap WM              67                        KB
 Processes Created        2
-Process Create Time      142,012
+Process Create Time      150,942
 Request Message Count    26
-Request Message Bytes    39,392
+Request Message Bytes    39,808
 Reply Message Count      15
-Reply Message Bytes      38,760
+Reply Message Bytes      38,840
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>prepare s1 from select distinct d from tstat ;
@@ -498,25 +510,25 @@ Scr. Write Count         0
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_272_S1 ;
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_279_S1 ;
 
-*** ERROR[8923] The given Query Id MXID11000009156212358279905535000000000000206U3333300_272_S1 is not found.
+*** ERROR[8923] The given Query Id MXID11000004343212360895605883001000000000206U3333300_279_S1 is not found.
 
 --- SQL operation failed with errors.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_272_S1 ;
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_279_S1 ;
 
-*** ERROR[8923] The given Query Id MXID11000009156212358279905535000000000000206U3333300_272_S1 is not found.
+*** ERROR[8923] The given Query Id MXID11000004343212360895605883001000000000206U3333300_279_S1 is not found.
 
 --- SQL operation failed with errors.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_281_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_281_S1
-Compile Start Time       2017/04/06 23:05:33.259103
-Compile End Time         2017/04/06 23:05:33.259721
-Compile Elapsed Time                 0:00:00.000618
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_288_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_288_S1
+Compile Start Time       2017/05/07 05:40:41.529514
+Compile End Time         2017/05/07 05:40:41.530838
+Compile Elapsed Time                 0:00:00.001324
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -547,11 +559,11 @@ Last Suspend Time        -1
 Stats Collection Type    ACCUMULATED_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_281_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_281_S1
-Compile Start Time       2017/04/06 23:05:33.259103
-Compile End Time         2017/04/06 23:05:33.259721
-Compile Elapsed Time                 0:00:00.000618
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_288_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_288_S1
+Compile Start Time       2017/05/07 05:40:41.529514
+Compile End Time         2017/05/07 05:40:41.530838
+Compile Elapsed Time                 0:00:00.001324
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -584,10 +596,10 @@ Stats Collection Type    ACCUMULATED_STATS
 --- SQL operation complete.
 >>log;
 >>display statistics for qid current;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_281_S1
-Compile Start Time       2017/04/06 23:05:33.259103
-Compile End Time         2017/04/06 23:05:33.259721
-Compile Elapsed Time                 0:00:00.000618
+Qid                      MXID11000004343212360895605883001000000000206U3333300_288_S1
+Compile Start Time       2017/05/07 05:40:41.529514
+Compile End Time         2017/05/07 05:40:41.530838
+Compile Elapsed Time                 0:00:00.001324
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -619,10 +631,10 @@ Stats Collection Type    ACCUMULATED_STATS
 
 --- SQL operation complete.
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_281_S1
-Compile Start Time       2017/04/06 23:05:33.259103
-Compile End Time         2017/04/06 23:05:33.259721
-Compile Elapsed Time                 0:00:00.000618
+Qid                      MXID11000004343212360895605883001000000000206U3333300_288_S1
+Compile Start Time       2017/05/07 05:40:41.529514
+Compile End Time         2017/05/07 05:40:41.530838
+Compile Elapsed Time                 0:00:00.001324
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -666,10 +678,10 @@ Stats Collection Type    ACCUMULATED_STATS
 --- SQL command prepared.
 >>log;
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -704,11 +716,11 @@ Stats Collection Type    PERTABLE_STATS
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -739,11 +751,11 @@ Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -778,11 +790,11 @@ Stats Collection Type    PERTABLE_STATS
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ACCUMULATED;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ACCUMULATED;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -813,11 +825,11 @@ Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ACCUMULATED;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ACCUMULATED;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -850,10 +862,10 @@ Stats Collection Type    PERTABLE_STATS
 --- SQL operation complete.
 >>log;
 >>display statistics for qid current;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -885,10 +897,10 @@ Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -920,10 +932,10 @@ Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
 >>display statistics for qid current accumulated ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -955,10 +967,10 @@ Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
 >>get statistics for qid current accumulated ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -994,24 +1006,24 @@ Stats Collection Type    PERTABLE_STATS
 D          
 -----------
 
-         12
          11
          21
          22
+         12
 
 --- 4 row(s) selected.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1029,7 +1041,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1037,7 +1049,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
-SQL Process Busy Time    5,884
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1047,34 +1059,34 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
 Sort TopN                -1
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              7,088              4,227
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              20,398              10,610
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1092,7 +1104,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1100,7 +1112,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
-SQL Process Busy Time    5,884
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1110,38 +1122,38 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
 Sort TopN                -1
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              7,088              4,227
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              20,398              10,610
 
 --- SQL operation complete.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ACCUMULATED;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ACCUMULATED;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1159,7 +1171,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1171,8 +1183,8 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           4,227
-SQL Process Busy Time    5,884
+SE IO MAX Time           10,610
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1182,26 +1194,29 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_286_S1 ACCUMULATED;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_293_S1 ACCUMULATED;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1219,7 +1234,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1231,8 +1246,8 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           4,227
-SQL Process Busy Time    5,884
+SE IO MAX Time           10,610
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1242,27 +1257,30 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>log;
 >>display statistics for qid current;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1280,7 +1298,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1288,7 +1306,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
-SQL Process Busy Time    5,884
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1298,34 +1316,34 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
 Sort TopN                -1
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              7,088              4,227
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              20,398              10,610
 
 --- SQL operation complete.
 >>get statistics for qid current ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1343,7 +1361,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1351,7 +1369,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
-SQL Process Busy Time    5,884
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1361,34 +1379,34 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
 Sort TopN                -1
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              7,088              4,227
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              20,398              10,610
 
 --- SQL operation complete.
 >>display statistics for qid current accumulated;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1406,7 +1424,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1418,8 +1436,8 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           4,227
-SQL Process Busy Time    5,884
+SE IO MAX Time           10,610
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1429,26 +1447,29 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>get statistics for qid current accumulated;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_286_S1
-Compile Start Time       2017/04/06 23:05:39.345617
-Compile End Time         2017/04/06 23:05:39.388433
-Compile Elapsed Time                 0:00:00.042816
-Execute Start Time       2017/04/06 23:05:45.596219
-Execute End Time         2017/04/06 23:05:45.609391
-Execute Elapsed Time                 0:00:00.013172
+Qid                      MXID11000004343212360895605883001000000000206U3333300_293_S1
+Compile Start Time       2017/05/07 05:40:49.935790
+Compile End Time         2017/05/07 05:40:49.977030
+Compile Elapsed Time                 0:00:00.041240
+Execute Start Time       2017/05/07 05:40:58.496745
+Execute End Time         2017/05/07 05:40:58.522185
+Execute Elapsed Time                 0:00:00.025440
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1466,7 +1487,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:05:45.606884
+First Row Returned Time  2017/05/07 05:40:58.520309
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1478,8 +1499,8 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           4,227
-SQL Process Busy Time    5,884
+SE IO MAX Time           10,610
+SQL Process Busy Time    15,419
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1489,21 +1510,24 @@ SQL Heap WM              10,338                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    27
-Request Message Bytes    39,552
+Request Message Bytes    39,968
 Reply Message Count      15
-Reply Message Bytes      39,144
+Reply Message Bytes      39,264
+BMO Space Buffer Size    0
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       UNKNOWN
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>log;
 >>obey PQIDOUT;
->>SET SESSION DEFAULT PARENT_QID 'MXID11000009156212358279905535000000000000206U3333300_286_S1';
+>>SET SESSION DEFAULT PARENT_QID 'MXID11000004343212360895605883001000000000206U3333300_293_S1';
 
 --- SQL operation complete.
 >>prepare s1 from select distinct d from tstat ;
@@ -1513,11 +1537,11 @@ Scr. Write Count         0
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_300_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_300_S1
-Compile Start Time       2017/04/06 23:05:54.780156
-Compile End Time         2017/04/06 23:05:54.780786
-Compile Elapsed Time                 0:00:00.000630
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_307_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_307_S1
+Compile Start Time       2017/05/07 05:41:07.096980
+Compile End Time         2017/05/07 05:41:07.097700
+Compile Elapsed Time                 0:00:00.000720
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -1529,7 +1553,7 @@ Query Type               SQL_SELECT_NON_UNIQUE
 Sub Query Type           SQL_STMT_NA
 Estimated Accessed Rows  0
 Estimated Used Rows      0
-Parent Qid               MXID11000009156212358279905535000000000000206U3333300_286_S1
+Parent Qid               MXID11000004343212360895605883001000000000206U3333300_293_S1
 Parent Query System      SAME
 Child Qid                NONE
 Number of SQL Processes  1
@@ -1548,11 +1572,11 @@ Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_300_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_300_S1
-Compile Start Time       2017/04/06 23:05:54.780156
-Compile End Time         2017/04/06 23:05:54.780786
-Compile Elapsed Time                 0:00:00.000630
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_307_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_307_S1
+Compile Start Time       2017/05/07 05:41:07.096980
+Compile End Time         2017/05/07 05:41:07.097700
+Compile Elapsed Time                 0:00:00.000720
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -1564,7 +1588,7 @@ Query Type               SQL_SELECT_NON_UNIQUE
 Sub Query Type           SQL_STMT_NA
 Estimated Accessed Rows  0
 Estimated Used Rows      0
-Parent Qid               MXID11000009156212358279905535000000000000206U3333300_286_S1
+Parent Qid               MXID11000004343212360895605883001000000000206U3333300_293_S1
 Parent Query System      SAME
 Child Qid                NONE
 Number of SQL Processes  1
@@ -1594,11 +1618,11 @@ Stats Collection Type    PERTABLE_STATS
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_302_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_302_S1
-Compile Start Time       2017/04/06 23:05:57.786576
-Compile End Time         2017/04/06 23:05:57.787052
-Compile Elapsed Time                 0:00:00.000476
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_309_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_309_S1
+Compile Start Time       2017/05/07 05:41:17.587174
+Compile End Time         2017/05/07 05:41:17.588229
+Compile Elapsed Time                 0:00:00.001055
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -1629,11 +1653,11 @@ Last Suspend Time        -1
 Stats Collection Type    PERTABLE_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_302_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_302_S1
-Compile Start Time       2017/04/06 23:05:57.786576
-Compile End Time         2017/04/06 23:05:57.787052
-Compile Elapsed Time                 0:00:00.000476
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_309_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_309_S1
+Compile Start Time       2017/05/07 05:41:17.587174
+Compile End Time         2017/05/07 05:41:17.588229
+Compile Elapsed Time                 0:00:00.001055
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -1680,11 +1704,11 @@ Stats Collection Type    PERTABLE_STATS
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -1715,11 +1739,11 @@ Last Suspend Time        -1
 Stats Collection Type    OPERATOR_STATS
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
 Execute Start Time       -1
 Execute End Time         -1
 Execute Elapsed Time                 0:00:00.000000
@@ -1766,14 +1790,14 @@ D
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1791,7 +1815,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1802,27 +1826,27 @@ Stats Collection Type    OPERATOR_STATS
 
 LC   RC   Id   PaId ExId Frag TDB Name                 DOP     Dispatches      Oper CPU Time  Est. Records Used  Act. Records Used    Details
 
-10   .    11   .    5    0    EX_ROOT                  1                5                  8                  0                  4              24 815
-9    .    10   11   4    0    EX_SPLIT_TOP             1                5                  7                  2                  4              24
-8    .    9    10   4    0    EX_SEND_TOP              2               10                800                  2                  4              32
-7    .    8    9    4    2    EX_SEND_BOTTOM           2               17                144                  2                  4              32
-6    .    7    8    4    2    EX_SPLIT_BOTTOM          2                7                 14                  2                  4              24 3583
-5    .    6    7    3    2    EX_HASH_GRBY             2                6              2,638                  1                  4              24 0|0|0
-4    .    5    6    2    2    EX_SPLIT_TOP             2               11                 13                100                  4              24
-3    .    4    5    2    2    EX_SEND_TOP              4               18                774                100                  4              32
-2    .    3    4    2    3    EX_SEND_BOTTOM           4               35                176                100                  4              32
-1    .    2    3    2    3    EX_SPLIT_BOTTOM          2                8                 22                100                  4              24 1983
-.    .    1    2    1    3    EX_TRAF_KEY_SELECT       2               12              5,355                100                  4              24 TRAFODION.SCH.TSTAT|4|176
-
---- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 ;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+10   .    11   .    5    0    EX_ROOT                  1                5                 10                  0                  4              24 1975
+9    .    10   11   4    0    EX_SPLIT_TOP             1                5                 19                  2                  4              24
+8    .    9    10   4    0    EX_SEND_TOP              2               10              1,946                  2                  4              32
+7    .    8    9    4    2    EX_SEND_BOTTOM           2               21                135                  2                  4              32
+6    .    7    8    4    2    EX_SPLIT_BOTTOM          2                7                  9                  2                  4              24 5956
+5    .    6    7    3    2    EX_HASH_GRBY             2                6              3,978                  1                  4              24 0|0|0
+4    .    5    6    2    2    EX_SPLIT_TOP             2               11                 22                100                  4              24
+3    .    4    5    2    2    EX_SEND_TOP              4               18              1,812                100                  4              32
+2    .    3    4    2    3    EX_SEND_BOTTOM           4               42                237                100                  4              32
+1    .    2    3    2    3    EX_SPLIT_BOTTOM          2                8                 60                100                  4              24 11007
+.    .    1    2    1    3    EX_TRAF_KEY_SELECT       2                4             10,710                100                  4              24 TRAFODION.SCH.TSTAT|4|176
+
+--- SQL operation complete.
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 ;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1840,7 +1864,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1851,31 +1875,31 @@ Stats Collection Type    OPERATOR_STATS
 
 LC   RC   Id   PaId ExId Frag TDB Name                 DOP     Dispatches      Oper CPU Time  Est. Records Used  Act. Records Used    Details
 
-10   .    11   .    5    0    EX_ROOT                  1                5                  8                  0                  4              24 815
-9    .    10   11   4    0    EX_SPLIT_TOP             1                5                  7                  2                  4              24
-8    .    9    10   4    0    EX_SEND_TOP              2               10                800                  2                  4              32
-7    .    8    9    4    2    EX_SEND_BOTTOM           2               17                144                  2                  4              32
-6    .    7    8    4    2    EX_SPLIT_BOTTOM          2                7                 14                  2                  4              24 3583
-5    .    6    7    3    2    EX_HASH_GRBY             2                6              2,638                  1                  4              24 0|0|0
-4    .    5    6    2    2    EX_SPLIT_TOP             2               11                 13                100                  4              24
-3    .    4    5    2    2    EX_SEND_TOP              4               18                774                100                  4              32
-2    .    3    4    2    3    EX_SEND_BOTTOM           4               35                176                100                  4              32
-1    .    2    3    2    3    EX_SPLIT_BOTTOM          2                8                 22                100                  4              24 1983
-.    .    1    2    1    3    EX_TRAF_KEY_SELECT       2               12              5,355                100                  4              24 TRAFODION.SCH.TSTAT|4|176
+10   .    11   .    5    0    EX_ROOT                  1                5                 10                  0                  4              24 1975
+9    .    10   11   4    0    EX_SPLIT_TOP             1                5                 19                  2                  4              24
+8    .    9    10   4    0    EX_SEND_TOP              2               10              1,946                  2                  4              32
+7    .    8    9    4    2    EX_SEND_BOTTOM           2               21                135                  2                  4              32
+6    .    7    8    4    2    EX_SPLIT_BOTTOM          2                7                  9                  2                  4              24 5956
+5    .    6    7    3    2    EX_HASH_GRBY             2                6              3,978                  1                  4              24 0|0|0
+4    .    5    6    2    2    EX_SPLIT_TOP             2               11                 22                100                  4              24
+3    .    4    5    2    2    EX_SEND_TOP              4               18              1,812                100                  4              32
+2    .    3    4    2    3    EX_SEND_BOTTOM           4               42                237                100                  4              32
+1    .    2    3    2    3    EX_SPLIT_BOTTOM          2                8                 60                100                  4              24 11007
+.    .    1    2    1    3    EX_TRAF_KEY_SELECT       2                4             10,710                100                  4              24 TRAFODION.SCH.TSTAT|4|176
 
 --- SQL operation complete.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 ACCUMULATED;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 ACCUMULATED;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1893,7 +1917,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1905,8 +1929,8 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           3,572
-SQL Process Busy Time    6,381
+SE IO MAX Time           12,163
+SQL Process Busy Time    18,938
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1916,26 +1940,29 @@ SQL Heap WM              10,341                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    28
-Request Message Bytes    39,712
+Request Message Bytes    40,128
 Reply Message Count      15
-Reply Message Bytes      42,416
+Reply Message Bytes      42,696
+BMO Space Buffer Size    256
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 ACCUMULATED;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 ACCUMULATED;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -1953,7 +1980,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -1965,8 +1992,8 @@ Accessed Rows            4
 Used Rows                4
 SE IOs                   4
 SE IO Bytes              176
-SE IO MAX Time           3,572
-SQL Process Busy Time    6,381
+SE IO MAX Time           12,163
+SQL Process Busy Time    18,938
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -1976,30 +2003,33 @@ SQL Heap WM              10,341                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    28
-Request Message Bytes    39,712
+Request Message Bytes    40,128
 Reply Message Count      15
-Reply Message Bytes      42,416
+Reply Message Bytes      42,696
+BMO Space Buffer Size    256
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
+Sort TopN                -1
 
 --- SQL operation complete.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 PERTABLE;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 PERTABLE;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -2017,7 +2047,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -2025,7 +2055,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    OPERATOR_STATS
-SQL Process Busy Time    6,381
+SQL Process Busy Time    18,938
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -2035,34 +2065,34 @@ SQL Heap WM              10,341                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    28
-Request Message Bytes    39,712
+Request Message Bytes    40,128
 Reply Message Count      15
-Reply Message Bytes      42,416
+Reply Message Bytes      42,696
+BMO Space Buffer Size    256
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
 Sort TopN                -1
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              6,690              3,572
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              22,124              12,163
 
 --- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 PERTABLE;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 PERTABLE;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -2080,7 +2110,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -2088,7 +2118,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    OPERATOR_STATS
-SQL Process Busy Time    6,381
+SQL Process Busy Time    18,938
 UDR Process Busy Time    0
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
@@ -2098,38 +2128,38 @@ SQL Heap WM              10,341                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    28
-Request Message Bytes    39,712
+Request Message Bytes    40,128
 Reply Message Count      15
-Reply Message Bytes      42,416
+Reply Message Bytes      42,696
+BMO Space Buffer Size    256
+BMO Space Buffer Count   0
+BMO Interim Row Count    0
 Scr. Overflow Mode       DISK
 Scr. File Count          0
-Scr. Buffer Blk Size     0
-Scr. Buffer Blks Read    0
-Scr. Buffer Blks Written 0
+Scr. IO Size             0
 Scr. Read Count          0
 Scr. Write Count         0
+Scr. IO Max Time         0
 Sort TopN                -1
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              6,690              3,572
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              22,124              12,163
 
 --- SQL operation complete.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 PROGRESS;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 PROGRESS;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -2147,7 +2177,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -2155,7 +2185,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    OPERATOR_STATS
-SQL Process Busy Time    6,381
+SQL Process Busy Time    18,938
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
 SQL Heap Allocated       200                       KB
@@ -2164,33 +2194,31 @@ SQL Heap WM              10,341                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    28
-Request Message Bytes    39,712
+Request Message Bytes    40,128
 Reply Message Count      15
-Reply Message Bytes      42,416
-
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              6,690              3,572
-
-   Id            TDBName               Mode       DOP     TopN             CPUTime
-             BMOHeapUsed   BMOHeapAllocated          BMOHeapWM       BMOSpaceBufSz      BMOSpaceBufCnt
- ScrFileCnt    ScrIOSize          ScrIORead       ScrIOWritten           ScrIOTime        ScrIOMaxTime
-    6       EX_HASH_GRBY               DISK         2       -1               2,638
-                       0                  0                  0                 256                   0
-    0                 -1                  0                  0                   0                   0
-
---- SQL operation complete.
->>get statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 PROGRESS;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+Reply Message Bytes      42,696
+
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              22,124              12,163
+
+   Id             TDBName                Mode       DOP      TopN            BMOPhase     InterimRowCount             CPUTime
+              BMOHeapUsed    BMOHeapAllocated           BMOHeapWM       BMOSpaceBufSz      BMOSpaceBufCnt
+               ScrFileCnt           ScrIOSize           ScrIORead        ScrIOWritten           ScrIOTime        ScrIOMaxTime
+    6        EX_HASH_GRBY                DISK         2        -1           READ_ROWS                   0               3,978
+                        4               1,024               7,687                 256                   0
+                        0                  -1                   0                   0                   0                   0
+
+--- SQL operation complete.
+>>get statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 PROGRESS;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                 0:00:00.037137
 State                    CLOSE
 Rows Affected            0
 SQL Error Code           100
@@ -2208,7 +2236,7 @@ Transaction Id           -1
 Source String            select distinct d from tstat ;
 SQL Source Length        30
 Rows Returned            4
-First Row Returned Time  2017/04/06 23:06:07.000444
+First Row Returned Time  2017/05/07 05:41:26.564755
 Last Error before AQR    0
 Number of AQR retries    0
 Delay before AQR         0
@@ -2216,7 +2244,7 @@ No. of times reclaimed   0
 Cancel Time              -1
 Last Suspend Time        -1
 Stats Collection Type    OPERATOR_STATS
-SQL Process Busy Time    6,381
+SQL Process Busy Time    18,938
 SQL Space Allocated      896                       KB
 SQL Space Used           766                       KB
 SQL Heap Allocated       200                       KB
@@ -2225,37 +2253,35 @@ SQL Heap WM              10,341                    KB
 Processes Created        0
 Process Create Time      0
 Request Message Count    28
-Request Message Bytes    39,712
+Request Message Bytes    40,128
 Reply Message Count      15
-Reply Message Bytes      42,416
+Reply Message Bytes      42,696
 
-       ID       DOP         Table Name
-   Records Accessed       Records Used   HBase/Hive   HBase/Hive      HBase/Hive IO      HBase/Hive IO
-   Estimated/Actual   Estimated/Actual          IOs    IO MBytes           Sum Time           Max Time
-        1         2   TRAFODION.SCH.TSTAT
-                  0                100
-                  4                  4            4            0              6,690              3,572
+   Id       DOP          Table Name
+  EstRowsAccess       ActRowsAccess    EstRowsUsed         ActRowsUsed              SE_IOs         SE_IO_Bytes       SE_IO_SumTime       SE_IO_MaxTime
+    1         2   TRAFODION.SCH.TSTAT
+              0                   4            100                   4                   4                   0              22,124              12,163
 
-   Id            TDBName               Mode       DOP     TopN             CPUTime
-             BMOHeapUsed   BMOHeapAllocated          BMOHeapWM       BMOSpaceBufSz      BMOSpaceBufCnt
- ScrFileCnt    ScrIOSize          ScrIORead       ScrIOWritten           ScrIOTime        ScrIOMaxTime
-    6       EX_HASH_GRBY               DISK         2       -1               2,638
-                       0                  0                  0                 256                   0
-    0                 -1                  0                  0                   0                   0
+   Id             TDBName                Mode       DOP      TopN            BMOPhase     InterimRowCount             CPUTime
+              BMOHeapUsed    BMOHeapAllocated           BMOHeapWM       BMOSpaceBufSz      BMOSpaceBufCnt
+               ScrFileCnt           ScrIOSize           ScrIORead        ScrIOWritten           ScrIOTime        ScrIOMaxTime
+    6        EX_HASH_GRBY                DISK         2        -1           READ_ROWS                   0               3,978
+                        4               1,024               7,687                 256                   0
+                        0                  -1                   0                   0                   0                   0
 
 --- SQL operation complete.
 >>log;
 >>SET SESSION DEFAULT STATISTICS_VIEW_TYPE 'DEFAULT' ;
 
 --- SQL operation complete.
->>display statistics for QID MXID11000009156212358279905535000000000000206U3333300_305_S1 DEFAULT;
-Qid                      MXID11000009156212358279905535000000000000206U3333300_305_S1
-Compile Start Time       2017/04/06 23:06:00.886062
-Compile End Time         2017/04/06 23:06:00.933429
-Compile Elapsed Time                 0:00:00.047367
-Execute Start Time       2017/04/06 23:06:06.989107
-Execute End Time         2017/04/06 23:06:07.002116
-Execute Elapsed Time                 0:00:00.013009
+>>display statistics for QID MXID11000004343212360895605883001000000000206U3333300_312_S1 DEFAULT;
+Qid                      MXID11000004343212360895605883001000000000206U3333300_312_S1
+Compile Start Time       2017/05/07 05:41:21.930615
+Compile End Time         2017/05/07 05:41:21.967829
+Compile Elapsed Time                 0:00:00.037214
+Execute Start Time       2017/05/07 05:41:26.529910
+Execute End Time         2017/05/07 05:41:26.567047
+Execute Elapsed Time                

<TRUNCATED>


[6/7] incubator-trafodion git commit: [TRAFODION-2420] RMS enhancements

Posted by se...@apache.org.
[TRAFODION-2420] RMS enhancements

Fix for junk values seen in variable_info column for some of the counters


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/42d63bed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/42d63bed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/42d63bed

Branch: refs/heads/master
Commit: 42d63bed5a40009428b36a07f709847319558afd
Parents: 1449032
Author: selvaganesang <se...@esgyn.com>
Authored: Wed May 10 18:55:11 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Wed May 10 18:55:11 2017 +0000

----------------------------------------------------------------------
 core/sql/executor/ExStats.cpp | 11 +++++------
 core/sql/executor/ExStats.h   |  4 ++--
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/42d63bed/core/sql/executor/ExStats.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExStats.cpp b/core/sql/executor/ExStats.cpp
index 56a0a9d..bc8979e 100644
--- a/core/sql/executor/ExStats.cpp
+++ b/core/sql/executor/ExStats.cpp
@@ -1913,11 +1913,10 @@ void ExFragRootOperStats::getVariableStatsInfo(char * dataBuffer,
 		"SpaceUsed: %u SpaceTotal: %u HeapUsed: %u HeapTotal: %u HeapWM: %u "
 		"Newprocess: %u NewprocessTime: %Ld reqMsgCnt: %Ld "
 		"regMsgBytes: %Ld replyMsgCnt: %Ld replyMsgBytes: %Ld "
-		"PMemUsed: %Ld scrOverFlowMode: %d sortTopN: %Ld"
+		"PMemUsed: %Ld scrOverFlowMode: %d sortTopN: %d "
 		"scrFileCount: %d bmoSpaceBufferSize: %d bmoSpaceBufferCount: %Ld scrIOSize: %d " 
 		"scrWriteCount:%Ld scrReadCount: %Ld scrIOMaxTime: %Ld bmoInterimRowCount: %Ld udrCpuTime: %Ld "
-		"maxWaitTime: %Ld avgWaitTime: %Ld "
-		"hdfsAccess: %Ld ",
+		"maxWaitTime: %Ld avgWaitTime: %Ld hdfsAccess: %d ",
 		cpuTime_,
 		(((txtVal = getTextVal()) != NULL) ? txtVal : "NULL"),
 		stmtIndex_,
@@ -5072,7 +5071,7 @@ void ExMeasStats::getVariableStatsInfo(char * dataBuffer, char * datalen,
     "statsRowType: %d Newprocess: %u NewprocessTime: %Ld Timeouts: %u NumSorts: %u SortElapsedTime: %Ld "
     "SpaceTotal: %d  SpaceUsed: %d HeapTotal: %d HeapUsed: %d HeapWM: %u CpuTime: %Ld "
     "reqMsgCnt: %Ld reqMsgBytes: %Ld replyMsgCnt: %Ld "
-    "replyMsgBytes: %Ld scrOverflowMode: %d sortTopN: %Ld"
+    "replyMsgBytes: %Ld scrOverflowMode: %d sortTopN: %d "
     "scrFileCount: %d bmoSpaceBufferSize: %d bmoSpaceBufferCount: %Ld scrIoSize: %d "
     "scrWriteCount: %Ld scrReadCount: %Ld scrIOMaxTime: %Ld interimRowCount: %Ld udrCpuTime: %Ld ",
 	      statType(),
@@ -10588,10 +10587,10 @@ void ExBMOStats::getVariableStatsInfo(char * dataBuffer,
   char *buf = dataBuffer;
   str_sprintf (
        buf,
-       "statsRowType: %d explainTdbId: %d bmoPhase: %s bmoIntCount: %Ld estMemory: %0.2f bmoHeapUsed: %d bmoHeapTotal: %d bmoHeapWM: %d "
+       "statsRowType: %d explainTdbId: %d bmoPhase: %s bmoIntCount: %Ld estMemory: %f bmoHeapUsed: %d bmoHeapTotal: %d bmoHeapWM: %d "
        "bmoSpaceBufferSize: %d bmoSpaceBufferCount: %d "
        "scrOverFlowMode: %d scrFileCount: %d scrBufferBlockSize: %d scrBuffferRead: %d scrBufferWritten: %d "
-       "scrWriteCount: %Ld scrReadCount: %Ld topN: %Ld scrIOSize: %d scrIOTime: %Ld scrIOMaxTime: %Ld ",
+       "scrWriteCount: %Ld scrReadCount: %Ld sortTopN: %d scrIOSize: %d scrIOTime: %Ld scrIOMaxTime: %Ld ",
         statType(),
         getExplainNodeId(),
         getBmoPhaseStr(),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/42d63bed/core/sql/executor/ExStats.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExStats.h b/core/sql/executor/ExStats.h
index 280e924..d15d36b 100644
--- a/core/sql/executor/ExStats.h
+++ b/core/sql/executor/ExStats.h
@@ -1199,7 +1199,7 @@ public:
   {
     scratchOverflowMode_ = overflowMode;
   }
-  inline void setTopN(Int64 size) 
+  inline void setTopN(Int32 size) 
   { 
     topN_ = size;
   }
@@ -1467,7 +1467,7 @@ private:
   Int64 interimRowCount_;
   Int64 scratchIOMaxTime_;
   Int64 udrCpuTime_;
-  Int64 topN_;
+  Int32 topN_;
   // process id of this fragment instance (to correlate it with MEASURE data)
   // Also used by logic on runtimestats/CancelBroker.cpp
   SB_Phandle_Type phandle_;


[5/7] incubator-trafodion git commit: Merge branch 'master' of git://git.apache.org/incubator-trafodion into trafodion-2420_4

Posted by se...@apache.org.
Merge branch 'master' of git://git.apache.org/incubator-trafodion into trafodion-2420_4

Conflicts:
	core/sql/executor/ex_sort.cpp
	core/sql/executor/ex_sort.h


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/1449032c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/1449032c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/1449032c

Branch: refs/heads/master
Commit: 1449032c2a016ada311e415a7013a662c21d6358
Parents: e771901 bf3e8d0
Author: selvaganesang <se...@esgyn.com>
Authored: Tue May 9 04:17:15 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Tue May 9 04:17:15 2017 +0000

----------------------------------------------------------------------
 .../run_full_trafodion_backup.sh                |   2 +-
 .../sql/scripts/install_hadoop_regr_test_env    | 102 +--
 core/sqf/sql/scripts/install_local_hadoop       |  15 +-
 core/sql/executor/ex_sort.cpp                   | 304 +++++---
 core/sql/executor/ex_sort.h                     |  34 +-
 core/sql/optimizer/OptimizerSimulator.cpp       |   2 +-
 core/sql/regress/executor/EXPECTED130           | 220 +++---
 core/sql/regress/executor/TEST130               |  90 +--
 core/sql/regress/hive/EXPECTED003               |   6 +-
 core/sql/regress/hive/EXPECTED005               | 104 +--
 core/sql/regress/hive/EXPECTED009               |  22 +-
 core/sql/regress/hive/EXPECTED018               | 717 ++++++++++---------
 core/sql/regress/hive/FILTER005                 |   4 +-
 core/sql/regress/hive/TEST003                   |  52 +-
 .../hive/TEST003_create_hive_tables.hive        |  24 +-
 core/sql/regress/hive/TEST005                   |  48 +-
 core/sql/regress/hive/TEST005_a.hive.sql        |  16 +-
 core/sql/regress/hive/TEST009                   |   6 +-
 core/sql/regress/hive/TEST009_a.hive.sql        |   4 +-
 core/sql/regress/hive/TEST009_b.hive.sql        |   2 +-
 core/sql/regress/hive/TEST018                   | 148 ++--
 .../hive/TEST018_create_hive_tables.hive        |  14 +-
 core/sql/sort/SortUtil.cpp                      |  98 ++-
 core/sql/sort/SortUtil.h                        |   6 +-
 core/sql/sqlcomp/nadefaults.cpp                 |  14 +-
 25 files changed, 1095 insertions(+), 959 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1449032c/core/sql/executor/ex_sort.cpp
----------------------------------------------------------------------
diff --cc core/sql/executor/ex_sort.cpp
index 1482bb9,f631b45..c92a38e
--- a/core/sql/executor/ex_sort.cpp
+++ b/core/sql/executor/ex_sort.cpp
@@@ -857,9 -941,22 +952,24 @@@ short ExSortTcb::workUp(
  	    if (qparent_.up->isFull()){
  	      return workStatus(WORK_OK); // parent queue is full. Just return
  	    }
 +	    if (bmoStats_)
 +               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_RECV_PHASE); 
- 
+ 	    
+ 	    //First time reaching here and before calling
+ 	    //sortReceive, release the buffers used during
+ 	    //sortSend phase ONLY if sort overflowed( by this
+ 	    //time, all sort records are in scratch files).
+ 	    //Overflow does not happen in TopNSort. Partial sort
+ 	    //has a separate receive pool.
+ 	    if((sortSendPool_ != NULL) &&  //not yet released
+ 	       (!pstate.noOverflow_) &&    //overflow happened
+ 	       (!sortTdb().partialSort())) //not partial sort
+ 	    {
+ 	      
+ 	      deleteAndReallocateSortPool();
+ 	    }
+ 	        
+ 	    
  	    ex_queue_entry * pentry = qparent_.up->getTailEntry();
  	    rc = sortReceive(pentry_down, request, pentry, FALSE,
  			     pentry_down->downState.parentIndex,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1449032c/core/sql/executor/ex_sort.h
----------------------------------------------------------------------
diff --cc core/sql/executor/ex_sort.h
index 4822aea,0e435f3..aa09b8f
--- a/core/sql/executor/ex_sort.h
+++ b/core/sql/executor/ex_sort.h
@@@ -136,17 -137,8 +137,19 @@@ public
      SORT_CANCEL_CHILD,
      SORT_DONE_WITH_QND
      };
 +
 +  // Change ExSortTcb::SortPhaseStr[] when a new value is added to this enum
 +  // Add new value before SORT_PHASE_END
 +  enum SortPhase  {
 +    SORT_PREP_PHASE,
 +    SORT_SEND_PHASE,
 +    SORT_RECV_PHASE,
 +    SORT_MERGE_PHASE,
 +    SORT_PHASE_END
 +  };
 +  static const char *SortPhaseStr[];
+ private:
 -  void deleteAndReallocateSortPool();
++   void deleteAndReallocateSortPool();
  protected:
    friend class   ExSortTdb;
    friend class   ExSortPrivateState;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1449032c/core/sql/sort/SortUtil.cpp
----------------------------------------------------------------------


[7/7] incubator-trafodion git commit: Merge [TRAFODION-2420] PR 1087 RMS Enhancements

Posted by se...@apache.org.
Merge [TRAFODION-2420] PR 1087 RMS Enhancements


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/f28cc089
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/f28cc089
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/f28cc089

Branch: refs/heads/master
Commit: f28cc0894c0a96b5081ebd44b04aba02741f45bf
Parents: ef4a294 42d63be
Author: selvaganesang <se...@apache.org>
Authored: Wed May 10 22:48:17 2017 +0000
Committer: selvaganesang <se...@apache.org>
Committed: Wed May 10 22:48:17 2017 +0000

----------------------------------------------------------------------
 .../native/ResStatisticsStatement.cpp           |   72 +-
 .../jdbc_type2/native/ResStatisticsStatement.h  |    9 +
 .../odbc/nsksrvrcore/ResStatisticsStatement.cpp |   88 +-
 .../odbc/nsksrvrcore/ResStatisticsStatement.h   |    7 +
 core/sql/cli/sqlcli.h                           |    2 +
 core/sql/comexe/ComTdbHashGrby.h                |    2 +
 core/sql/executor/ExExeUtil.h                   |    8 +-
 core/sql/executor/ExExeUtilGetStats.cpp         |  444 ++--
 core/sql/executor/ExStats.cpp                   |  311 +--
 core/sql/executor/ExStats.h                     |   30 +-
 core/sql/executor/ex_hash_grby.cpp              |   21 +-
 core/sql/executor/ex_hash_grby.h                |   11 +
 core/sql/executor/ex_hashj.cpp                  |   26 +-
 core/sql/executor/ex_hashj.h                    |   18 +-
 core/sql/executor/ex_sort.cpp                   |   17 +-
 core/sql/executor/ex_sort.h                     |   13 +-
 core/sql/parser/sqlparser.y                     |    2 +-
 core/sql/regress/core/EXPECTEDRTS               | 1903 +++++++++---------
 core/sql/regress/core/FILTERRTS                 |   18 +-
 core/sql/sort/Qsort.cpp                         |    9 +-
 core/sql/sort/Qsort.h                           |    3 +-
 core/sql/sort/SortAlgo.cpp                      |    3 +-
 core/sql/sort/SortAlgo.h                        |    3 +-
 core/sql/sort/SortTopN.cpp                      |    9 +-
 core/sql/sort/SortTopN.h                        |    3 +-
 core/sql/sort/SortUtil.cpp                      |    8 +-
 core/sql/sort/TourTree.cpp                      |    8 +-
 core/sql/sort/TourTree.h                        |    1 +
 28 files changed, 1623 insertions(+), 1426 deletions(-)
----------------------------------------------------------------------



[3/7] incubator-trafodion git commit: [TRAFODION-2420] RMS enhancements

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_hashj.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_hashj.cpp b/core/sql/executor/ex_hashj.cpp
index 1828a0f..dd783eb 100644
--- a/core/sql/executor/ex_hashj.cpp
+++ b/core/sql/executor/ex_hashj.cpp
@@ -131,6 +131,14 @@ digraph hasjoin {
 }
 */
 
+// In the reverse order of ex_hashj_tcb::HashJoinPhase
+const char *ex_hashj_tcb::HashJoinPhaseStr[] = {
+    "PHASE_END",
+    "PHASE_3",
+    "PHASE_2",
+    "PHASE_1"
+};
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 //  TDB procedures
@@ -1161,7 +1169,7 @@ ExWorkProcRetcode ex_hashj_tcb::workDown() {
 	// If new input matches the previous input, then reuse the old hash-table
 	if ( will_reuse_old_HT = isSameInputAgain(downParentEntry) ) {
 	  // the hash table is already prepared. Go on with phase 2 of the join
-	  pstate.setPhase(PHASE_2);
+	  pstate.setPhase(PHASE_2, bmoStats_);
 	  pstate.usePreviousHT();
 	  pstate.reliesOnIdx = prevReqIdx_;
 	  pstate.setState(HASHJ_READ_OUTER); // all set to start reading the outer
@@ -1226,7 +1234,7 @@ ExWorkProcRetcode ex_hashj_tcb::workDown() {
 	  // Even though we reuse, still need to finish up few things before
 	  // phase two; e.g., handle delayed or non-delayed left request
 	  pstate.setState(HASHJ_END_PHASE_1);
-	  pstate.setPhase(PHASE_1);  // needed ?  just in case ...
+	  pstate.setPhase(PHASE_1, bmoStats_);  // needed ?  just in case ...
 	}
 	else { // no reuse
 	  // Change the request: only one row from the right child is needed
@@ -1647,7 +1655,7 @@ short ex_hashj_tcb::workReadInner() {
 
   switch (rightEntry->upState.status) {
   case ex_queue::Q_OK_MMORE: {
-   
+
     if ( isAllOrNothing_ ) {  // Special case: AntiSemi HJ, no search expr
       pstate.setReadRightRow(); // this request actualy read a row from the right
       anyRightRowsRead_ = TRUE ; // Got a right row --> left rows are not needed !!
@@ -2033,9 +2041,8 @@ void ex_hashj_tcb::workEndPhase1() {
   } // if logDiagnostics
 
 #endif
-
   // all clusters are prepared. Go on with phase 2 of the join
-  pstate.setPhase(PHASE_2);
+  pstate.setPhase(PHASE_2, bmoStats_);
 
   // from now on, we want to charge the next phase with time
   if (hashJoinStats_)
@@ -2370,7 +2377,7 @@ void ex_hashj_tcb::workEndPhase2() {
   // all clusters are prepared. Go on with phase 3 of the join
   // set the first inner cluster to read
   clusterDb_->setClusterToRead(clusterDb_->getClusterList());
-  pstate.setPhase(PHASE_3);
+  pstate.setPhase(PHASE_3, bmoStats_);
   // from now on, we want to charge the next phase with time
   if (hashJoinStats_)
     hashJoinStats_->incPhase();
@@ -2545,6 +2552,9 @@ short ex_hashj_tcb::workProbe() {
     workAtp_->getTupp(hashJoinTdb().extRightRowAtpIndex1_).
       setDataPointer(hashRow->getData());
 
+    if (bmoStats_)
+       bmoStats_->incInterimRowCount();
+
     // evaluate beforeJoinPredicate
     beforeJoinPred = phase2 ? beforeJoinPred1_ : beforeJoinPred2_ ;
 
@@ -2566,7 +2576,7 @@ short ex_hashj_tcb::workProbe() {
     // if right-outer join, mark this right row
     if (isRightJoin())  
       hashRow->setBit(TRUE);
-
+   
     // if this is a left outer join or semi join and if we are in a hash loop,
     // the outer cluster has a bitmap. Update this bitmap now
     if( oCluster && oCluster->hasBitMap() )  oCluster->updateBitMap();
@@ -3482,7 +3492,7 @@ ExWorkProcRetcode ExUniqueHashJoinTcb::workUp()
           else
             {
               pstate.setState(HASHJ_READ_OUTER);
-	      pstate.setPhase(PHASE_2);
+	      pstate.setPhase(PHASE_2, bmoStats_);
 
               // from now on, we want to charge the next phase with time
               if (hashJoinStats_)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_hashj.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_hashj.h b/core/sql/executor/ex_hashj.h
index b22a95f..c2e5130 100644
--- a/core/sql/executor/ex_hashj.h
+++ b/core/sql/executor/ex_hashj.h
@@ -39,7 +39,7 @@
  */
 
 #include "cluster.h"
-
+#include "ExStats.h"
 /////////////////////////////////////////////////////////////////////////////
 // Task Definition Block
 // for a description of the expressions see GerRelJoin.C
@@ -110,8 +110,6 @@ private:
   // ---------------------------------------------------------------------
 };
 
-
-
 /////////////////////////////////////////////////////
 // Task control block
 /////////////////////////////////////////////////////
@@ -162,11 +160,17 @@ public:
   };
 
   // the phase of the hash join algorithm
+  // Change ex_hashj_tcb::HashJoinPhaseStr when you add new value to this enum
+  // New phase enum value should be added before PHASE_END
   enum HashJoinPhase {
     PHASE_1,
     PHASE_2,
-    PHASE_3
+    PHASE_3,
+    PHASE_END
   };
+
+  static const char *HashJoinPhaseStr[];
+
   virtual NA_EIDPROC NABoolean needStatsEntry();
   virtual NA_EIDPROC ExOperStats *doAllocateStatsEntry(CollHeap *heap,
                                                        ComTdb *tdb);
@@ -451,7 +455,7 @@ public:
   inline ex_hashj_tcb::HashJoinState getState();
   inline void setOldState(ex_hashj_tcb::HashJoinState state);
   inline ex_hashj_tcb::HashJoinState getOldState();
-  inline void setPhase(ex_hashj_tcb::HashJoinPhase phase);
+  inline void setPhase(ex_hashj_tcb::HashJoinPhase phase, ExBMOStats *bmoStats);
   inline ex_hashj_tcb::HashJoinPhase getPhase();
   inline void usePreviousHT();
   inline NABoolean usingPreviousHT();
@@ -487,8 +491,10 @@ inline ex_hashj_tcb::HashJoinState ex_hashj_private_state::getOldState() {
   return (oldState_);
 }
 
-inline void ex_hashj_private_state::setPhase(ex_hashj_tcb::HashJoinPhase phase) {
+inline void ex_hashj_private_state::setPhase(ex_hashj_tcb::HashJoinPhase phase, ExBMOStats *bmoStats) {
   phase_ = phase;
+  if (bmoStats)
+     bmoStats->setBmoPhase(ex_hashj_tcb::HashJoinPhase::PHASE_END-phase);
 }
 
 inline ex_hashj_tcb::HashJoinPhase ex_hashj_private_state::getPhase() {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_sort.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_sort.cpp b/core/sql/executor/ex_sort.cpp
index b56cdce..1482bb9 100644
--- a/core/sql/executor/ex_sort.cpp
+++ b/core/sql/executor/ex_sort.cpp
@@ -55,6 +55,14 @@
 void ReleaseTupp(void * td);
 void CaptureTupp(void * td);
 
+// Dont exceed more than 11 characters
+const char *ExSortTcb::SortPhaseStr[] = {
+  "SORT_PREP",
+  "SORT_SEND",
+  "SORT_RECV",
+  "SORT_MERGE"
+};
+
 NABoolean ExSortTcb::needStatsEntry()
 {
   ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();
@@ -685,7 +693,8 @@ short ExSortTcb::workUp()
 		sortDiag_ = NULL;              // reset
                 // LCOV_EXCL_STOP
 	      }
-	    
+	    if (bmoStats_)
+               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_PREP_PHASE);
 	    setupPoolBuffers(pentry_down);
  
       if((request == ex_queue::GET_N) &&
@@ -737,6 +746,8 @@ short ExSortTcb::workUp()
 	    ex_queue_entry * centry = qchild_.up->getHeadEntry();
 	    ex_queue::up_status child_status = centry->upState.status;
 	    ex_queue_entry *upEntry = qparent_.up->getTailEntry();
+	    if (bmoStats_)
+               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_SEND_PHASE); 
 	    
 	    rc = sortSend(centry, child_status, pentry_down, upEntry, 
 			  FALSE, // not sort from top
@@ -846,6 +857,8 @@ short ExSortTcb::workUp()
 	    if (qparent_.up->isFull()){
 	      return workStatus(WORK_OK); // parent queue is full. Just return
 	    }
+	    if (bmoStats_)
+               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_RECV_PHASE); 
 
 	    ex_queue_entry * pentry = qparent_.up->getTailEntry();
 	    rc = sortReceive(pentry_down, request, pentry, FALSE,
@@ -1279,6 +1292,8 @@ short ExSortTcb::sortSend(ex_queue_entry * srcEntry,
 		  }
 	      }
 	  }
+        if (bmoStats_)
+           bmoStats_->incInterimRowCount();
 	// LCOV_EXCL_STOP
 	rc = sortUtil_->sortSend(dataPointer,
 				 newRecLen,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_sort.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_sort.h b/core/sql/executor/ex_sort.h
index 72229cd..4822aea 100644
--- a/core/sql/executor/ex_sort.h
+++ b/core/sql/executor/ex_sort.h
@@ -136,7 +136,17 @@ public:
     SORT_CANCEL_CHILD,
     SORT_DONE_WITH_QND
     };
-  
+
+  // Change ExSortTcb::SortPhaseStr[] when a new value is added to this enum
+  // Add new value before SORT_PHASE_END
+  enum SortPhase  {
+    SORT_PREP_PHASE,
+    SORT_SEND_PHASE,
+    SORT_RECV_PHASE,
+    SORT_MERGE_PHASE,
+    SORT_PHASE_END
+  };
+  static const char *SortPhaseStr[];
 protected:
   friend class   ExSortTdb;
   friend class   ExSortPrivateState;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 0ed6bc5..bf579aa 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -15275,7 +15275,7 @@ exe_util_get_statistics : TOK_GET TOK_STATISTICS stats_merge_clause get_statisti
                   {
                     stats =
                       new (PARSERHEAP ()) ExeUtilGetStatistics
-                    (*$5, NULL,
+                    (*$5, ($7 ? (char*)$7->data() : NULL),
                       PARSERHEAP (), SQLCLI_STATS_REQ_QID, (short)$6, -1); /*RtsQueryId::ANY_QUERY_*/
                   }
                   $$ = stats;