Tomas Vondra <tomas.vondra@xxxxxxxxxxxxxxx> writes: > Most of the time (3460ms) is spent in the sequential scan on > chr_simple_val, and the seqscan on chr_emp_position is taking ~330ms). > Combined that's 3790ms out of 3797ms, so the join is pretty much > irrelevant. > Either the seqscans are causing a lot of I/O, or maybe the f_sel_* > functions in the filter are expensive. Judging by how few rows are in > the tables (not sure how large the tables are), I'd guess it's the > latter ... Hard to say without knowing what the functions do etc. I think the OP is wishing that the filter functions for the larger table would be postponed till after the join condition is applied. I'm a little dubious that that's going to save anything meaningful; but maybe increasing the cost attributed to those functions would persuade the planner to try it that way. First though, does forcing a nestloop plan (turn off enable_hashjoin, and enable_mergejoin too if needed) produce the shape of plan you want? And if so, is it actually faster? Only if those things are true is it going to be worth messing with costing parameters. regards, tom lane