CREATE TABLE test (x1 int, x2 int, x3 int, x4 int, payload text);
INSERT INTO test (x1,x2,x3,x4,payload)
  SELECT x%100,x%100,x%100,x%100,repeat('abc', 128)
  FROM generate_series(1,1E4) AS x;
CREATE TABLE test1 (x1 int, x2 int, x3 int, x4 int, payload1 text);
INSERT INTO test1 SELECT * FROM test;
CREATE INDEX ON test (x1,x2,x3,x4);
ANALYZE test, test1;

EXPLAIN (ANALYZE, TIMING OFF)
SELECT * FROM test t1 NATURAL JOIN test1 t2 WHERE t2.x1 < 1;
CREATE STATISTICS stx1 ON x1,x2,x3,x4 FROM test;
CREATE STATISTICS stx2 ON x1,x2,x3,x4 FROM test1;
VACUUM ANALYZE test,test1;
EXPLAIN (ANALYZE, TIMING OFF)
SELECT * FROM test t1 NATURAL JOIN test1 t2 WHERE t2.x1 < 1;

/*
 Nested Loop  (cost=0.30..1108.95 rows=1 width=792) (actual rows=10000 loops=1)
   ->  Seq Scan on test1 t2  (cost=0.00..681.00 rows=100 width=404) (actual rows=100 loops=1)
         Filter: (x1 < 1)
         Rows Removed by Filter: 9900
   ->  Memoize  (cost=0.30..4.44 rows=1 width=404) (actual rows=100 loops=100)
         Cache Key: t2.x1, t2.x2, t2.x3, t2.x4
         Cache Mode: logical
         Hits: 99  Misses: 1  Evictions: 0  Overflows: 0  Memory Usage: 43kB
         ->  Index Scan using test_x1_x2_x3_x4_idx on test t1  (cost=0.29..4.43 rows=1 width=404) (actual rows=100 loops=1)
               Index Cond: ((x1 = t2.x1) AND (x2 = t2.x2) AND (x3 = t2.x3) AND (x4 = t2.x4))

 Nested Loop  (cost=0.30..964.22 rows=10000 width=792) (actual rows=10000 loops=1)
   ->  Seq Scan on test1 t2  (cost=0.00..681.00 rows=100 width=404) (actual rows=100 loops=1)
         Filter: (x1 < 1)
         Rows Removed by Filter: 9900
   ->  Memoize  (cost=0.30..4.44 rows=1 width=404) (actual rows=100 loops=100)
         Cache Key: t2.x1, t2.x2, t2.x3, t2.x4
         Cache Mode: logical
         Hits: 99  Misses: 1  Evictions: 0  Overflows: 0  Memory Usage: 43kB
         ->  Index Scan using test_x1_x2_x3_x4_idx on test t1  (cost=0.29..4.43 rows=1 width=404) (actual rows=100 loops=1)
               Index Cond: ((x1 = t2.x1) AND (x2 = t2.x2) AND (x3 = t2.x3) AND (x4 = t2.x4))
*/