SET enable_bitmapscan = 'off';
DROP STATISTICS IF EXISTS aestat;

CREATE TABLE a AS (
	SELECT
		gs % 10 AS x,
		(gs % 10 + (gs/10::int4) % 10) % 10 AS y,
		(gs / 100)::int4 AS z
	FROM generate_series(1,1000) AS gs
);
INSERT INTO a (SELECT gs,gs,gs FROM generate_series(1000,2000) AS gs);

ALTER TABLE a ADD PRIMARY KEY (x,y,z);
CREATE INDEX ON a(x);
ANALYZE a;

EXPLAIN
SELECT * FROM a WHERE x=1 AND y=1 AND z=1;

CREATE STATISTICS aestat(dependencies,ndistinct) ON x,y,z FROM a;
ANALYZE a;

EXPLAIN
SELECT * FROM a WHERE x=1 AND y=1 AND z=1;

/*
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Only Scan using a_pkey on a  (cost=0.28..8.30 rows=1 width=12)
   Index Cond: ((x = 1) AND (y = 1) AND (z = 1))
(2 rows)

CREATE STATISTICS
ANALYZE
                             QUERY PLAN                             
--------------------------------------------------------------------
 Index Scan using a_x_idx on a  (cost=0.28..18.97 rows=28 width=12)
   Index Cond: (x = 1)
   Filter: ((y = 1) AND (z = 1))
(3 rows)
*/