Smarter version of join selectivity patch handling cases like this:
explain select * from outer_tab join inner_tab using(x,y) where x=1;
QUERY PLAN
------------------------------------------------------------------------------------------------
Nested Loop (cost=0.42..1815.47 rows=10 width=12)
Join Filter: (outer_tab.y = inner_tab.y)
-> Seq Scan on outer_tab (cost=0.00..1791.00 rows=1 width=12)
Filter: (x = 1)
-> Index Only Scan using inner_tab_x_y_idx on inner_tab
(cost=0.42..24.35 rows=10 width=8)
Index Cond: (x = 1)
(6 rows)
--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company