*** pgsql/src/backend/optimizer/path/joinpath.c 2008/08/14 18:47:59 1.117 --- pgsql/src/backend/optimizer/path/joinpath.c 2008/10/04 21:56:53 1.118 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.116 2008/03/24 21:53:03 tgl Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.117 2008/08/14 18:47:59 tgl Exp $ * *------------------------------------------------------------------------- */ *************** match_unsorted_outer(PlannerInfo *root, *** 408,417 **** * If the cheapest inner path is a join or seqscan, we should consider * materializing it. (This is a heuristic: we could consider it * always, but for inner indexscans it's probably a waste of time.) */ ! if (!(IsA(inner_cheapest_total, IndexPath) || ! IsA(inner_cheapest_total, BitmapHeapPath) || ! IsA(inner_cheapest_total, TidPath))) matpath = (Path *) create_material_path(innerrel, inner_cheapest_total); --- 408,422 ---- * If the cheapest inner path is a join or seqscan, we should consider * materializing it. (This is a heuristic: we could consider it * always, but for inner indexscans it's probably a waste of time.) + * Also skip it if the inner path materializes its output anyway. */ ! if (!(inner_cheapest_total->pathtype == T_IndexScan || ! inner_cheapest_total->pathtype == T_BitmapHeapScan || ! inner_cheapest_total->pathtype == T_TidScan || ! inner_cheapest_total->pathtype == T_Material || ! inner_cheapest_total->pathtype == T_FunctionScan || ! inner_cheapest_total->pathtype == T_CteScan || ! inner_cheapest_total->pathtype == T_WorkTableScan)) matpath = (Path *) create_material_path(innerrel, inner_cheapest_total);