diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 7a2c20b145..0367e1aacd 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -1382,6 +1382,10 @@ sort_inner_and_outer(PlannerInfo *root, List *all_pathkeys; ListCell *l; + /* Nothing to do if there are no available mergejoin clauses */ + if (extra->mergeclause_list == NIL) + return; + /* * We only consider the cheapest-total-cost input paths, since we are * assuming here that a sort is required. We will consider