diff --git a/.unreleased/pr_7768 b/.unreleased/pr_7768 new file mode 100644 index 00000000000..26ff3b54bb6 --- /dev/null +++ b/.unreleased/pr_7768 @@ -0,0 +1 @@ +Fixes: #7768 Remove costing index scan of hypertable parent diff --git a/src/planner/planner.c b/src/planner/planner.c index 2e0cb0b6cda..67c1c2366bc 100644 --- a/src/planner/planner.c +++ b/src/planner/planner.c @@ -1375,6 +1375,19 @@ timescaledb_set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, Rang #endif TS_FALLTHROUGH; default: + /* + * Set the indexlist for a hypertable parent to NIL since we + * should not try to do any index scans on hypertable parents, + * similar to how it works for partitioned tables. + * + * This can happen when building a merge join path and computing + * cost for it. See get_actual_variable_range(). + * + * This has to be after the hypertable is expanded, since the + * indexlist is used during hypertable expansion. + */ + if (reltype == TS_REL_HYPERTABLE) + rel->indexlist = NIL; apply_optimizations(root, reltype, rel, rte, ht); break; }