HAWQ-580. Set analyze vseg number for partition and no-partition table 
separately.


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

Branch: refs/heads/HAWQ-546
Commit: 71aa704c8545dd5d2048f50491d791e713952638
Parents: 9357b31
Author: hzhang2 <zhanghuan...@163.com>
Authored: Thu Mar 24 10:12:36 2016 +0800
Committer: Oleksandr Diachenko <odiache...@pivotal.io>
Committed: Wed Mar 30 17:23:30 2016 -0700

----------------------------------------------------------------------
 src/backend/commands/analyze.c    | 14 +++++++++-----
 src/backend/commands/copy.c       |  2 +-
 src/backend/postmaster/identity.c |  6 ++++--
 src/backend/utils/misc/guc.c      | 16 +++++++++++++---
 src/include/utils/guc.h           |  3 ++-
 5 files changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/71aa704c/src/backend/commands/analyze.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index ac12837..ae869da 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -821,19 +821,23 @@ static int calculate_virtual_segment_number(List* 
candidateOids) {
        int64 totalDataSize = 0;
        bool isHashRelationExist = false;
        int maxHashBucketNumber = 0;
-
+       bool isPartitionTableExist = false;
        foreach (le1, candidateOids)
        {
                Oid                             candidateOid      = InvalidOid;
                candidateOid = lfirst_oid(le1);
 
-               //Relation rel = (Relation)lfirst(le1);
+               PartStatus ps = rel_part_status(candidateOid);
+               if(ps != PART_STATUS_NONE){
+                       isPartitionTableExist = true;
+               }
+
                Relation rel = relation_open(candidateOid, 
ShareUpdateExclusiveLock);
                if (candidateOid > 0 ) {
                        GpPolicy *targetPolicy = 
GpPolicyFetch(CurrentMemoryContext,
                                        candidateOid);
                        if(targetPolicy == NULL){
-                               return GetAnalyzeVSegNumLimit();
+                               return 
GetAnalyzeVSegNumLimit(isPartitionTableExist);
                        }
                        if (targetPolicy->nattrs > 0) {
                                isHashRelationExist = true;
@@ -860,8 +864,8 @@ static int calculate_virtual_segment_number(List* 
candidateOids) {
        }
        Assert(vsegNumber > 0);
        /*vsegNumber should be less than GetUtilPartitionNum*/
-       if(vsegNumber > GetAnalyzeVSegNumLimit()){
-               vsegNumber = GetAnalyzeVSegNumLimit();
+       if(vsegNumber > GetAnalyzeVSegNumLimit(isPartitionTableExist)){
+               vsegNumber = GetAnalyzeVSegNumLimit(isPartitionTableExist);
        }
 
        return vsegNumber;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/71aa704c/src/backend/commands/copy.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index e37fb83..2ed87e6 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1786,7 +1786,7 @@ static int calculate_virtual_segment_number(List* 
candidateOids) {
                        GpPolicy *targetPolicy = 
GpPolicyFetch(CurrentMemoryContext,
                                        candidateOid);
                        if(targetPolicy == NULL){
-                               return GetAnalyzeVSegNumLimit();
+                               return GetQueryVsegNum();
                        }
                        if (targetPolicy->nattrs > 0) {
                                isHashRelationExist = true;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/71aa704c/src/backend/postmaster/identity.c
----------------------------------------------------------------------
diff --git a/src/backend/postmaster/identity.c 
b/src/backend/postmaster/identity.c
index 1bb558d..02a2038 100644
--- a/src/backend/postmaster/identity.c
+++ b/src/backend/postmaster/identity.c
@@ -452,9 +452,11 @@ GetQEGangNum(void)
        return SegmentId.pid.init ? SegmentId.pid.gang_member_num : 0;
 }
 
-int    GetAnalyzeVSegNumLimit(void)
+int    GetAnalyzeVSegNumLimit(bool isPartitionTableExist)
 {
-       int nvseg = hawq_rm_nvseg_for_analyze_perquery_perseg_limit * 
slaveHostNumber;
+       int perSegLimit = isPartitionTableExist ? 
hawq_rm_nvseg_for_analyze_part_perquery_perseg_limit
+                       : 
hawq_rm_nvseg_for_analyze_nopart_perquery_perseg_limit;
+       int nvseg = perSegLimit * slaveHostNumber;
        while(nvseg > hawq_rm_nvseg_for_analyze_perquery_limit){
                nvseg -= slaveHostNumber;
        }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/71aa704c/src/backend/utils/misc/guc.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 9718f94..9477dbc 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -735,7 +735,8 @@ int  optimizer_samples_number;
 int  optimizer_log_failure;
 int default_hash_table_bucket_number;
 int hawq_rm_nvseg_for_copy_from_perquery;
-int hawq_rm_nvseg_for_analyze_perquery_perseg_limit;
+int hawq_rm_nvseg_for_analyze_nopart_perquery_perseg_limit;
+int hawq_rm_nvseg_for_analyze_part_perquery_perseg_limit;
 int hawq_rm_nvseg_for_analyze_perquery_limit;
 double   optimizer_cost_threshold;
 double  optimizer_nestloop_factor;
@@ -4529,15 +4530,24 @@ static struct config_int ConfigureNamesInt[] =
        },
 
        {
-               {"hawq_rm_nvseg_for_analyze_perquery_perseg_limit", 
PGC_USERSET, QUERY_TUNING_OTHER,
+               {"hawq_rm_nvseg_for_analyze_part_perquery_perseg_limit", 
PGC_USERSET, QUERY_TUNING_OTHER,
                        gettext_noop("Sets default virtual segment number per 
query per segment limit for analyze statement"),
                        NULL
                },
-               &hawq_rm_nvseg_for_analyze_perquery_perseg_limit,
+               &hawq_rm_nvseg_for_analyze_part_perquery_perseg_limit,
                4, 1, 65535, NULL, NULL
        },
 
        {
+               {"hawq_rm_nvseg_for_analyze_nopart_perquery_perseg_limit", 
PGC_USERSET, QUERY_TUNING_OTHER,
+                       gettext_noop("Sets default virtual segment number per 
query per segment limit for analyze statement"),
+                       NULL
+               },
+               &hawq_rm_nvseg_for_analyze_nopart_perquery_perseg_limit,
+               8, 1, 65535, NULL, NULL
+       },
+
+       {
                {"hawq_rm_nvseg_for_analyze_perquery_limit", PGC_USERSET, 
QUERY_TUNING_OTHER,
                        gettext_noop("Sets default virtual segment number per 
query limit for analyze statement"),
                        NULL

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/71aa704c/src/include/utils/guc.h
----------------------------------------------------------------------
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 4715f76..edab452 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -310,7 +310,8 @@ extern int Debug_dtm_action_segment;
 
 extern int default_hash_table_bucket_number;
 extern int hawq_rm_nvseg_for_copy_from_perquery;
-extern int hawq_rm_nvseg_for_analyze_perquery_perseg_limit;
+extern int hawq_rm_nvseg_for_analyze_nopart_perquery_perseg_limit;
+extern int hawq_rm_nvseg_for_analyze_part_perquery_perseg_limit;
 extern int hawq_rm_nvseg_for_analyze_perquery_limit;
 
 extern char *ConfigFileName;

Reply via email to