Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-17 Thread Etsuro Fujita
(2014/04/16 22:16), Hannu Krosing wrote: On 04/16/2014 01:35 PM, Etsuro Fujita wrote: Maybe I'm missing something, but I think that you can do what I think you'd like to do by the following procedure: No, what I'd like PostgreSQL to do is to 1. select the id+set from local table 2. select th

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-16 Thread Ashutosh Bapat
AFAIK, PostgreSQL's join nodes (except for hash join) consider one row at a time from outer table and match inner table rows one at a time. What needs to be done in the case you are suggesting is that it needs to consider all the rows of outer table, fetch their respective joining columns and then

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-16 Thread Hannu Krosing
On 04/16/2014 03:16 PM, Hannu Krosing wrote: > On 04/16/2014 01:35 PM, Etsuro Fujita wrote: >> (2014/04/16 6:55), Hannu Krosing wrote: > ... >> Maybe I'm missing something, but I think that you can do what I think >> you'd like to do by the following procedure: > No, what I'd like PostgreSQL to do

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-16 Thread Hannu Krosing
On 04/16/2014 01:35 PM, Etsuro Fujita wrote: > (2014/04/16 6:55), Hannu Krosing wrote: ... > > Maybe I'm missing something, but I think that you can do what I think > you'd like to do by the following procedure: No, what I'd like PostgreSQL to do is to 1. select the id+set from local table 2. sele

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-16 Thread Etsuro Fujita
(2014/04/16 6:55), Hannu Krosing wrote: -- CREATE EXTENSION postgres_fdw; CREATE SERVER loop foreign data wrapper postgres_fdw OPTIONS (port '5432', dbname 'testdb'); CREATE USER MAPPING FOR PUBLIC SERVER loop; create table onemillion ( id serial primary

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-15 Thread Hannu Krosing
On 04/16/2014 06:12 AM, Hannu Krosing wrote: > On 04/16/2014 01:25 AM, Tom Lane wrote: >> Hannu Krosing 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

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-15 Thread Hannu Krosing
On 04/16/2014 01:25 AM, Tom Lane wrote: > Hannu Krosing 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 wri

Re: [HACKERS] Question about optimising (Postgres_)FDW

2014-04-15 Thread Tom Lane
Hannu Krosing 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 onemilli

[HACKERS] Question about optimising (Postgres_)FDW

2014-04-15 Thread Hannu Krosing
Hi I am playing around with postgres_fdw and found that the following code ... -- CREATE EXTENSION postgres_fdw; CREATE SERVER loop foreign data wrapper postgres_fdw OPTIONS (port '5432', dbname 'testdb'); CREATE USER MAPPING FOR PUBLIC SERVER loop; create ta