QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=1473.20..2665.70 rows=4630 width=152) Merge Cond: ("outer".slunit = "inner".un_name) Join Filter: ((("outer".sl_len * "outer".un_fact) >= ("outer".slminlen * "inner".un_fact)) AND (("outer".sl_len * "outer".un_fact) <= ("outer".slmaxlen * "inner".un_fact))) -> Sort (cost=1403.37..1424.20 rows=8333 width=132) Sort Key: sh.slunit -> Merge Join (cost=396.18..513.68 rows=8333 width=132) Merge Cond: ("outer".sl_unit = "inner".un_name) -> Sort (cost=326.35..330.51 rows=1667 width=112) Sort Key: s.sl_unit -> Merge Join (cost=139.66..237.16 rows=1667 width=112) Merge Cond: ("outer".slcolor = "inner".sl_color) Join Filter: (int4smaller("outer".sh_avail, "inner".sl_avail) >= 2) -> Sort (cost=69.83..72.33 rows=1000 width=60) Sort Key: sh.slcolor -> Seq Scan on shoe_data sh (cost=0.00..20.00 rows=1000 width=60) -> Sort (cost=69.83..72.33 rows=1000 width=52) Sort Key: s.sl_color -> Seq Scan on shoelace_data s (cost=0.00..20.00 rows=1000 width=52) -> Sort (cost=69.83..72.33 rows=1000 width=20) Sort Key: u.un_name -> Seq Scan on unit u (cost=0.00..20.00 rows=1000 width=20) -> Sort (cost=69.83..72.33 rows=1000 width=20) Sort Key: un.un_name -> Seq Scan on unit un (cost=0.00..20.00 rows=1000 width=20) (24 rows)