DELETE FROM pg_mv_statistic;

CREATE TABLE test_histogram (
    a FLOAT,
    b FLOAT,
    c FLOAT,
    d FLOAT,
    e FLOAT,
    f FLOAT,
    g FLOAT,
    h FLOAT,
    i FLOAT,
    j FLOAT,
    k FLOAT,
    l FLOAT,
    m FLOAT,
    n FLOAT,
    o FLOAT,
    p FLOAT,
    q FLOAT,
    r FLOAT,
    s FLOAT,
    t FLOAT,
    u FLOAT,
    v FLOAT,
    w FLOAT,
    x FLOAT,
    y FLOAT,
    z FLOAT
);

CREATE OR REPLACE FUNCTION randomize(p_value FLOAT, p_spread FLOAT) RETURNS FLOAT AS $$
    SELECT $1 + $2 * random() * random();
$$ LANGUAGE SQL;

INSERT INTO test_histogram
     SELECT randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05),
            randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10),
            randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05),
            randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10),
            randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05), randomize(v, 0.10), randomize(v, 0.05),
            randomize(v, 0.10)
       FROM (
           SELECT random() AS v FROM generate_series(1,1000000)
       ) foo;

ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (a,b);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (y,z);


ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (a,b,c);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c,d);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d,e);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e,f);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f,g);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g,h);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (t,u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (u,v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (v,w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (w,x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (x,y,z);

ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (a,b,c,d);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c,d,e);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d,e,f);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e,f,g);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f,g,h);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g,h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h,i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i,j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j,k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k,l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l,m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m,n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n,o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o,p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p,q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q,r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r,s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s,t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t,u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (t,u,v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (u,v,w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (v,w,x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (w,x,y,z);

ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (a,b,c,d,e);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c,d,e,f);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d,e,f,g);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e,f,g,h);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f,g,h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g,h,i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h,i,j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i,j,k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j,k,l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k,l,m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l,m,n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m,n,o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n,o,p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o,p,q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p,q,r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q,r,s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r,s,t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s,t,u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t,u,v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (t,u,v,w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (u,v,w,x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (v,w,x,y,z);

ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c,d,e,f,g);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d,e,f,g,h);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e,f,g,h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f,g,h,i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g,h,i,j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h,i,j,k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i,j,k,l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j,k,l,m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k,l,m,n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l,m,n,o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m,n,o,p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n,o,p,q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o,p,q,r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p,q,r,s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q,r,s,t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r,s,t,u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s,t,u,v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t,u,v,w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (t,u,v,w,x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (u,v,w,x,y,z);

ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c,d,e,f,g,h);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d,e,f,g,h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e,f,g,h,i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f,g,h,i,j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g,h,i,j,k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h,i,j,k,l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i,j,k,l,m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j,k,l,m,n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k,l,m,n,o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l,m,n,o,p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m,n,o,p,q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n,o,p,q,r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o,p,q,r,s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p,q,r,s,t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q,r,s,t,u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r,s,t,u,v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s,t,u,v,w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t,u,v,w,x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (t,u,v,w,x,y,z);

ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (b,c,d,e,f,g,h,i);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (c,d,e,f,g,h,i,j);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (d,e,f,g,h,i,j,k);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (e,f,g,h,i,j,k,l);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (f,g,h,i,j,k,l,m);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (g,h,i,j,k,l,m,n);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (h,i,j,k,l,m,n,o);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (i,j,k,l,m,n,o,p);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (j,k,l,m,n,o,p,q);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (k,l,m,n,o,p,q,r);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (l,m,n,o,p,q,r,s);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (m,n,o,p,q,r,s,t);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (n,o,p,q,r,s,t,u);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (o,p,q,r,s,t,u,v);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (p,q,r,s,t,u,v,w);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (q,r,s,t,u,v,w,x);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (r,s,t,u,v,w,x,y);
ALTER TABLE test_histogram ADD STATISTICS (histogram) ON (s,t,u,v,w,x,y,z);


ANALYZE test_histogram;

-- should be 151 (everything implies everything)
SELECT COUNT(*) FROM pg_mv_stats WHERE depsbytes IS NOT NULL;

EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100) AND (x <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100) AND (z <= 100);

EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100) AND (x <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100) AND (z <= 100);

TRUNCATE test_histogram;

INSERT INTO test_histogram
     SELECT v, v, v, v, v, v, v, v, v, v, 
            v, v, v, v, v, v, v, v, v, v, 
            v, v, v, v, v, v
       FROM (
           SELECT (mod(i,1000) * random() * random())::int AS v FROM generate_series(1,1000000) s(i)
       ) foo;

ANALYZE test_histogram;

-- should be 151 (everything implies everything)
SELECT COUNT(*) FROM pg_mv_stats WHERE depsbytes IS NOT NULL;

EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100) AND (x <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100) AND (z <= 100);

EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (d <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (h <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (l <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (p <= 100) AND (q <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (v <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100) AND (x <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100);
EXPLAIN SELECT * FROM test_histogram WHERE (a <= 100) AND (b <= 100) AND (c <= 100) AND (e <= 100) AND (f <= 100) AND (g <= 100) AND (i <= 100) AND (j <= 100) AND (k <= 100) AND (m <= 100) AND (n <= 100) AND (o <= 100) AND (q <= 100) AND (r <= 100) AND (s <= 100) AND (t <= 100) AND (u <= 100) AND (w <= 100) AND (x <= 100) AND (y <= 100) AND (z <= 100);
