Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a51023f
Enable chunk exclusion for DML
arajkumar Feb 26, 2026
9a52d84
Sync set_append_rel_size with upstream PostgreSQL
arajkumar Mar 2, 2026
7cde1e6
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Mar 2, 2026
e288dc0
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Mar 2, 2026
60b2ff0
move rowmark handling to expand_single_inheritance_child
arajkumar Mar 3, 2026
04d1722
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Mar 3, 2026
6690340
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Mar 4, 2026
2df7676
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Mar 4, 2026
697950e
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Mar 5, 2026
53662fd
fix: comment on MERGE
arajkumar Mar 6, 2026
4a9b37a
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Mar 6, 2026
3854a02
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Mar 10, 2026
4403d72
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Mar 11, 2026
9ba1b77
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Mar 16, 2026
182b172
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Mar 17, 2026
65745e1
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Apr 1, 2026
a30845e
Fix expectations for debug build
arajkumar Apr 1, 2026
1485d7a
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 2, 2026
c1ccb98
Extract tlist fixup logic into a function
arajkumar Apr 2, 2026
78b67e7
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 3, 2026
730d3d1
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 6, 2026
1fd6217
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Apr 10, 2026
d344cb5
Add GUC and remove duplicate code
arajkumar Apr 10, 2026
1a5796a
Address review: remove stale comment, fix compression test, add GUC test
arajkumar Apr 14, 2026
3c4a03c
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Apr 14, 2026
591b82f
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 15, 2026
d11e227
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Apr 15, 2026
f7a4e3a
Fix modify_exclusion expected output for PG15/16/17
arajkumar Apr 18, 2026
c356af9
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Apr 18, 2026
aab3959
Fix format
arajkumar Apr 20, 2026
6461804
Merge remote-tracking branch 'origin/main' into arajkumar/fix-ht-upda…
arajkumar Apr 20, 2026
33e22bd
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 22, 2026
db19de9
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 24, 2026
83bd8b5
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 27, 2026
18728e8
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 27, 2026
9a77e59
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
arajkumar Apr 29, 2026
2c01708
Merge branch 'main' into arajkumar/fix-ht-update-delete-slowness
akuzm Apr 29, 2026
1785ca2
tmp cleanup
akuzm Apr 29, 2026
85a5264
tmp cleanup
akuzm Apr 29, 2026
96e3a9d
fix
akuzm Apr 29, 2026
529cf7d
debug
akuzm Apr 29, 2026
8970894
remove unrelated change
akuzm Apr 29, 2026
4f3c0ed
fix + test
akuzm Apr 29, 2026
b101b6a
tmp
akuzm May 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/pr_9315
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implements: #9315 Enable chunk exclusion for DML
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ add_subdirectory(with_clause)
# file properties if the target was added in the same directory, so just move it
# all here.
set(IMPORTED_SOURCES import/allpaths.c import/heapswap.c import/list.c
import/planner.c import/ts_explain.c)
import/planner.c import/ts_explain.c import/ts_inherit.c)
set_source_files_properties(${IMPORTED_SOURCES} PROPERTIES SKIP_LINTING ON)
target_sources(${PROJECT_NAME} PRIVATE ${IMPORTED_SOURCES})
52 changes: 43 additions & 9 deletions src/import/allpaths.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
{
int parentRTindex = rti;
bool has_live_children;
#if PG18_GE
double parent_tuples;
#endif
double parent_rows;
double parent_size;
double *parent_attrsizes;
Expand All @@ -536,7 +539,11 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
*/
if (enable_partitionwise_join && rel->reloptkind == RELOPT_BASEREL &&
rte->relkind == RELKIND_PARTITIONED_TABLE &&
#if PG16_GE
bms_is_empty(rel->attr_needed[InvalidAttrNumber - rel->min_attr]))
#else
rel->attr_needed[InvalidAttrNumber - rel->min_attr] == NULL)
#endif
rel->consider_partitionwise_join = true;

/*
Expand All @@ -554,6 +561,9 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
* have zero rows and/or width, if they were excluded by constraints.
*/
has_live_children = false;
#if PG18_GE
parent_tuples = 0;
#endif
parent_rows = 0;
parent_size = 0;
nattrs = rel->max_attr - rel->min_attr + 1;
Expand All @@ -565,6 +575,10 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
int childRTindex;
RangeTblEntry *childRTE;
RelOptInfo *childrel;
#if PG16_GE
List *childrinfos;
ListCell *lc;
#endif
ListCell *parentvars;
ListCell *childvars;

Expand Down Expand Up @@ -606,6 +620,25 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
/*
* Constraint exclusion failed, so copy the parent's join quals and
* targetlist to the child, with appropriate variable substitutions.
*/
#if PG16_GE
childrinfos = NIL;
Comment thread
akuzm marked this conversation as resolved.
Outdated
foreach (lc, rel->joininfo)
{
RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);

if (!bms_overlap(rinfo->clause_relids, rel->nulling_relids))
childrinfos =
lappend(childrinfos, adjust_appendrel_attrs(root, (Node *) rinfo, 1, &appinfo));
}
childrel->joininfo = childrinfos;
#else
childrel->joininfo =
(List *) adjust_appendrel_attrs(root, (Node *) rel->joininfo, 1, &appinfo);
#endif

/*
* Now for the child's targetlist.
*
* NB: the resulting childrel->reltarget->exprs may contain arbitrary
* expressions, which otherwise would not occur in a rel's targetlist.
Expand All @@ -614,8 +647,6 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
* PlaceHolderVars.) XXX we do not bother to update the cost or width
* fields of childrel->reltarget; not clear if that would be useful.
*/
childrel->joininfo =
(List *) adjust_appendrel_attrs(root, (Node *) rel->joininfo, 1, &appinfo);
childrel->reltarget->exprs =
(List *) adjust_appendrel_attrs(root, (Node *) rel->reltarget->exprs, 1, &appinfo);

Expand Down Expand Up @@ -696,6 +727,9 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
*/
Assert(childrel->rows > 0);

#if PG18_GE
parent_tuples += childrel->tuples;
#endif
parent_rows += childrel->rows;
parent_size += childrel->reltarget->width * childrel->rows;

Expand All @@ -712,7 +746,8 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
Var *parentvar = (Var *) lfirst(parentvars);
Node *childvar = (Node *) lfirst(childvars);

if (IsA(parentvar, Var))
/* Only process Vars that belong to the parent rel */
Comment thread
akuzm marked this conversation as resolved.
Outdated
if (IsA(parentvar, Var) && parentvar->varno == parentRTindex)
{
int pndx = parentvar->varattno - rel->min_attr;
int32 child_width = 0;
Expand All @@ -739,17 +774,16 @@ ts_set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEn
int i;

Assert(parent_rows > 0);
#if PG18_GE
rel->tuples = parent_tuples;
#else
rel->tuples = parent_rows;
#endif
rel->rows = parent_rows;
rel->reltarget->width = rint(parent_size / parent_rows);
for (i = 0; i < nattrs; i++)
rel->attr_widths[i] = rint(parent_attrsizes[i] / parent_rows);

/*
* Set "raw tuples" count equal to "rows" for the appendrel; needed
* because some places assume rel->tuples is valid for any baserel.
*/
rel->tuples = parent_rows;

/*
* Note that we leave rel->pages as zero; this is important to avoid
* double-counting the appendrel tree in total_table_pages.
Expand Down
109 changes: 0 additions & 109 deletions src/import/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,115 +43,6 @@ static Node *replace_nestloop_params(PlannerInfo *root, Node *expr);
static Node *replace_nestloop_params_mutator(Node *node, PlannerInfo *root);
static Plan *inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe);

/* copied verbatim from optimizer/util/appendinfo.c at REL_17_6 */
void
ts_make_inh_translation_list(Relation oldrelation, Relation newrelation, Index newvarno,
AppendRelInfo *appinfo)
{
List *vars = NIL;
AttrNumber *pcolnos;
TupleDesc old_tupdesc = RelationGetDescr(oldrelation);
TupleDesc new_tupdesc = RelationGetDescr(newrelation);
Oid new_relid = RelationGetRelid(newrelation);
int oldnatts = old_tupdesc->natts;
int newnatts = new_tupdesc->natts;
int old_attno;
int new_attno = 0;

/* Initialize reverse-translation array with all entries zero */
appinfo->num_child_cols = newnatts;
appinfo->parent_colnos = pcolnos = (AttrNumber *) palloc0(newnatts * sizeof(AttrNumber));

for (old_attno = 0; old_attno < oldnatts; old_attno++)
{
Form_pg_attribute att;
char *attname;
Oid atttypid;
int32 atttypmod;
Oid attcollation;

att = TupleDescAttr(old_tupdesc, old_attno);
if (att->attisdropped)
{
/* Just put NULL into this list entry */
vars = lappend(vars, NULL);
continue;
}
attname = NameStr(att->attname);
atttypid = att->atttypid;
atttypmod = att->atttypmod;
attcollation = att->attcollation;

/*
* When we are generating the "translation list" for the parent table
* of an inheritance set, no need to search for matches.
*/
if (oldrelation == newrelation)
{
vars = lappend(vars,
makeVar(newvarno,
(AttrNumber) (old_attno + 1),
atttypid,
atttypmod,
attcollation,
0));
pcolnos[old_attno] = old_attno + 1;
continue;
}

/*
* Otherwise we have to search for the matching column by name.
* There's no guarantee it'll have the same column position, because
* of cases like ALTER TABLE ADD COLUMN and multiple inheritance.
* However, in simple cases, the relative order of columns is mostly
* the same in both relations, so try the column of newrelation that
* follows immediately after the one that we just found, and if that
* fails, let syscache handle it.
*/
if (new_attno >= newnatts || (att = TupleDescAttr(new_tupdesc, new_attno))->attisdropped ||
strcmp(attname, NameStr(att->attname)) != 0)
{
HeapTuple newtup;

newtup = SearchSysCacheAttName(new_relid, attname);
if (!HeapTupleIsValid(newtup))
elog(ERROR,
"could not find inherited attribute \"%s\" of relation \"%s\"",
attname,
RelationGetRelationName(newrelation));
new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attnum - 1;
Assert(new_attno >= 0 && new_attno < newnatts);
ReleaseSysCache(newtup);

att = TupleDescAttr(new_tupdesc, new_attno);
}

/* Found it, check type and collation match */
if (atttypid != att->atttypid || atttypmod != att->atttypmod)
elog(ERROR,
"attribute \"%s\" of relation \"%s\" does not match parent's type",
attname,
RelationGetRelationName(newrelation));
if (attcollation != att->attcollation)
elog(ERROR,
"attribute \"%s\" of relation \"%s\" does not match parent's collation",
attname,
RelationGetRelationName(newrelation));

vars = lappend(vars,
makeVar(newvarno,
(AttrNumber) (new_attno + 1),
atttypid,
atttypmod,
attcollation,
0));
pcolnos[new_attno] = old_attno + 1;
new_attno++;
}

appinfo->translated_vars = vars;
}

/* copied verbatim from planner.c */
struct PathTarget *
ts_make_partial_grouping_target(struct PlannerInfo *root, PathTarget *grouping_target)
Expand Down
3 changes: 0 additions & 3 deletions src/import/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

#include "export.h"

extern TSDLLEXPORT void ts_make_inh_translation_list(Relation oldrelation, Relation newrelation,
Index newvarno, AppendRelInfo *appinfo);

extern TSDLLEXPORT struct PathTarget *ts_make_partial_grouping_target(struct PlannerInfo *root,
PathTarget *grouping_target);

Expand Down
Loading
Loading