CREATE TABLE join_outer (id INTEGER, val INTEGER);
CREATE TABLE join_inner (id INTEGER, val INTEGER);
-- Insert data
INSERT INTO join_outer SELECT i, i % 10 FROM generate_series(1, 1000) i;
INSERT INTO join_inner SELECT i, i % 10 FROM generate_series(-50, 50) i;
ANALYZE join_outer,join_inner;

SET enable_hashjoin = 'off';
SET enable_mergejoin = 'off';

EXPLAIN ANALYZE VERBOSE
SELECT * FROM join_inner JOIN join_outer USING (id);

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.00..2779.51 rows=101 width=12) (actual time=6.923..13.809 rows=50.00 loops=1)
   Output: join_inner.id, join_inner.val, join_outer.val
   Join Filter: (join_inner.id = join_outer.id)
   Rows Removed by Join Filter: 100950
   ->  Seq Scan on public.join_inner  (cost=0.00..2.01 rows=101 width=8) (actual time=0.003..0.008 rows=101.00 loops=1)
         Output: join_inner.id, join_inner.val
         Buffers: shared hit=1
   ->  Seq Scan on public.join_outer  (cost=0.00..15.00 rows=1000 width=8) (actual time=0.003..0.054 rows=1000.00 loops=101)
         Output: join_outer.id, join_outer.val
         Buffers: shared hit=505
 
RESET enable_hashjoin;

 Hash Join  (cost=3.27..23.03 rows=101 width=12) (actual time=0.030..0.210 rows=50.00 loops=1)
   Output: join_inner.id, join_inner.val, join_outer.val
   Hash Cond: (join_outer.id = join_inner.id)
   Buffers: shared hit=6
   ->  Seq Scan on public.join_outer  (cost=0.00..15.00 rows=1000 width=8) (actual time=0.005..0.070 rows=1000.00 loops=1)
         Output: join_outer.id, join_outer.val
         Buffers: shared hit=5
   ->  Hash  (cost=2.01..2.01 rows=101 width=8) (actual time=0.023..0.023 rows=101.00 loops=1)
         Output: join_inner.id, join_inner.val
         Buckets: 1024  Batches: 1  Memory Usage: 12kB
         ->  Seq Scan on public.join_inner  (cost=0.00..2.01 rows=101 width=8) (actual time=0.001..0.007 rows=101.00 loops=1)
               Output: join_inner.id, join_inner.val
