Attached is the correct patch, sorry for the confusion.
If anyone's interested in testing it you can do so without the randomarray.c
file by using Pavel Stehule's solution for generating arrays:
postgres=# create table h as (select (random()*1000000)::integer as r, repeat('x',512)::text as t from
generate_series(1,1000000));
SELECT
postgres=# create index hri on h(r);
CREATE INDEX
postgres=# analyze h;
ANALYZE
postgres=# \timing
Timing is on.
postgres=# set preread_pages = 0; explain analyze select * from h where r = any (array(select
(1+random()*1000000)::integerfrom generate_series(1,100)));
postgres=# set preread_pages = 100; explain analyze select * from h where r = any (array(select
(1+random()*1000000)::integerfrom generate_series(1,100)));
postgres=# set preread_pages = 0; explain analyze select * from h where r = any (array(select
(1+random()*1000000)::integerfrom generate_series(1,100)));
postgres=# set preread_pages = 100; explain analyze select * from h where r = any (array(select
(1+random()*1000000)::integerfrom generate_series(1,100)));
postgres=# set preread_pages = 0; explain analyze select * from h where r = any (array(select
(1+random()*1000000)::integerfrom generate_series(1,100)));
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's 24x7 Postgres support!