This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new 8910a5b1fc hardcode the attributes of GpSegmentId in
GetContentIdsFromPlanForSingleRelation() (#15659)
8910a5b1fc is described below
commit 8910a5b1fcdf7bd4f826adaa8c4266933d1b347c
Author: Hongxu Ma <[email protected]>
AuthorDate: Wed Jun 7 11:55:29 2023 +0800
hardcode the attributes of GpSegmentId in
GetContentIdsFromPlanForSingleRelation() (#15659)
In a recent pgbench test, we found performance regression. After tested,
its dues to the commit: e8deb29ae0, and the bottleneck is the indexscan on
systable.
So, let's simply hardcode the attributes of GpSegmentId here since it's a
stable type in GP.
---
src/backend/cdb/cdbtargeteddispatch.c | 39 +++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/src/backend/cdb/cdbtargeteddispatch.c
b/src/backend/cdb/cdbtargeteddispatch.c
index f12e5203f1..b297164e27 100644
--- a/src/backend/cdb/cdbtargeteddispatch.c
+++ b/src/backend/cdb/cdbtargeteddispatch.c
@@ -43,6 +43,14 @@
#define PRINT_DISPATCH_DECISIONS_STRING ("print_dispatch_decisions")
+/**
+ * The attributes of GpSegmentId,
+ * you can find its static definition in heap.c (static FormData_pg_attribute
a8;)
+ */
+#define GP_SEGMENTID_TYPID INT4OID
+#define GP_SEGMENTID_TYPMOD -1
+#define GP_SEGMENTID_TYPCOLL 0
+#define GP_SEGMENTID_OPFAMILY 1977 /* integer_ops */
/* PRINT_DISPATCH_DECISIONS_STRING; */
@@ -156,23 +164,32 @@ GetContentIdsFromPlanForSingleRelation(PlannerInfo *root,
Plan *plan, int rangeT
*/
if (GpPolicyIsPartitioned(policy))
{
- Var *seg_id_var;
- Oid vartypeid;
- int32 type_mod;
- Oid type_coll;
PossibleValueSet pvs_segids;
Node **seg_ids;
int len;
int i;
List *contentIds = NULL;
- get_atttypetypmodcoll(rte->relid, GpSegmentIdAttributeNumber,
- &vartypeid,
&type_mod, &type_coll);
- seg_id_var = makeVar(rangeTableIndex,
-
GpSegmentIdAttributeNumber,
- vartypeid, type_mod,
type_coll, 0);
- Oid opclass = GetDefaultOpClass(vartypeid, HASH_AM_OID);
- Oid opfamily = get_opclass_family(opclass);
+ /**
+ * In previous code, we get the attributes of GpSegmentId
dynamically:
+ * get_atttypetypmodcoll(rte->relid,
GpSegmentIdAttributeNumber,
+ * &vartypeid,
&type_mod, &type_coll);
+ * Oid opclass = GetDefaultOpClass(vartypeid, HASH_AM_OID);
+ * Oid opfamily = get_opclass_family(opclass);
+ *
+ * But they caused the perf regression of pgbench. After test,
the bottleneck is
+ * the indexscan on systable.
+ *
+ * So, let's simply introduce GP_SEGMENTID_XXX macros to
hardcord them here
+ * since GpSegmentId is a stable type in GP: you can find its
static definition
+ * in heap.c (static FormData_pg_attribute a8;)
+ */
+ Var *seg_id_var = makeVar(rangeTableIndex,
+
GpSegmentIdAttributeNumber,
+
GP_SEGMENTID_TYPID, GP_SEGMENTID_TYPMOD, GP_SEGMENTID_TYPCOLL,
+ 0);
+ Oid opfamily = GP_SEGMENTID_OPFAMILY;
+
pvs_segids = DeterminePossibleValueSet((Node *) qualification,
(Node *) seg_id_var, opfamily);
if (!pvs_segids.isAnyValuePossible)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]