=?UTF-8?Q?Stanis=C5=82aw_Skonieczny?= <stanislaw.skonieczny@xxxxxxxxx> writes: > What bothers me is that the inner plan cost (7430940) is higher than the > outer plan cost (1131699). I think it is estimating (based on knowledge of the ranges of join keys in the two relations) that that input subplan won't need to be run to completion. See initial_cost_mergejoin in costsize.c. regards, tom lane