Hannu Krosing <hannu@2ndQuadrant.com> writes:
> Is there a way to force it to prefer a plan where the results of (select
> id from onemillion where data > '0.9' limit 100)
> are passed to FDW as a single IN ( = ANY(...)) query and are retrieved
> all at once ?
You could write the query like that:
select * from onemillion_pgfdw where id = any (array(select id from
onemillion where data > '0.9' limit 100));
Or at least you should be able to, except when I try it I get
explain analyze
select * from onemillion_pgfdw where id = any (array(select id from
onemillion where data > '0.9' limit 100));
ERROR: operator does not exist: integer = integer[]
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
CONTEXT: Remote SQL command: EXPLAIN SELECT id, inserted, data FROM public.onemillion WHERE ((id = ANY ((SELECT
null::integer[]))))
so there's something the remote-estimate code is getting wrong here.
(It seems to work without remote_estimate, though.)
regards, tom lane