title: Postgres Slow join with where clause
body: <p>I already making index on both table. But its still pretty slow. And its so fast without the where clause.</p>
  <pre><code>EXPLAIN ANALYZE  SELECT date, a , b, c FROM t1 JOIN t2 using (date, a)  where date = current_date
  ;
  
  Nest2d Loop  (cost=0.71..12.75 rows=1 width=22) (actual time=0.343..50925.262 rows=87956 loops=1)
    Join Filt2r: (t1.a = t2.a)
    Rows Removed by Join Filt2r: 262988440
    -&gt;  Index Scan using t1_date_idx1 on t1 t1  (cost=0.42..8.44 rows=1 width=15) (actual time=0.022..20.240 rows=87956 loops=1)
          Index Cond: (date = CURRENT_DATE)
    -&gt;  Index Scan using t2_date_idx on t2 t2  (cost=0.29..4.30 rows=1 width=15) (actual time=0.005..0.353 rows=2991 loops=87956)
          Index Cond: (date = CURRENT_DATE)
  Planning time: 0.151 ms
  Execution time: 50930.327 ms
  
  </code></pre>
  <p>Without where clause:</p>
  <pre><code>EXPLAIN ANALYZE  SELECT date, a , b, c FROM t1 JOIN t2 using (date, a) 
  ;
  
  Hash Join  (cost=349.55..11993.24 rows=182123 width=22) (actual time=4.741..61.881 rows=182123 loops=1)
    Hash Cond: ((t1.date = t2.date) AND (t1.a = t2.a))
    -&gt;  Seq Scan on t1 t1  (cost=0.00..8001.23 rows=182123 width=15) (actual time=2.921..17.651 rows=182123 loops=1)
    -&gt;  Hash  (cost=259.82..259.82 rows=5982 width=15) (actual time=1.765..1.765 rows=5982 loops=1)
          Buckets: 8192  Batches: 1  Memory Usage: 350kB
          -&gt;  Seq Scan on t2 t2  (cost=0.00..259.82 rows=5982 width=15) (actual time=0.115..0.908 rows=5982 loops=1)
  Planning time: 0.280 ms
  Execution time: 66.400 ms
  </code></pre>