Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)

2019-05-06 Thread Jeff Janes
On Mon, May 6, 2019 at 11:53 AM Jeff Janes wrote: > On Mon, May 6, 2019 at 11:38 AM Vitaly Baranovsky < > barvetalfor...@gmail.com> wrote: > >> Thank you, Jeff! >> >> We'll be looking forward to the next version of Postgres in this case. >> >> As far as I understand, you've answered about

Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)

2019-05-06 Thread Vitaly Baranovsky
Ough, I believed I had use_remote_estimate = true in my database, but it was false :( With use_remote_estimate = true everything works well! Here is explain analyze with use_remote_estimate = true: "Nested Loop (cost=100.45..108.97 rows=10 width=16) (actual time=1.037..1.037 rows=0

Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)

2019-05-06 Thread Jeff Janes
On Mon, May 6, 2019 at 11:38 AM Vitaly Baranovsky wrote: > Thank you, Jeff! > > We'll be looking forward to the next version of Postgres in this case. > > As far as I understand, you've answered about sending filtering condition > to a foreign server... Could you, please, clarify about another

Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)

2019-05-06 Thread Tom Lane
Jeff Janes writes: > It works the way you want in version 12, which is currently under > development and should be released in 5 months or so. Even in older versions, the OP would get a significantly smarter plan after setting use_remote_estimate = on. I think the core issue here is that we

Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)

2019-05-06 Thread Vitaly Baranovsky
Thank you, Jeff! We'll be looking forward to the next version of Postgres in this case. As far as I understand, you've answered about sending filtering condition to a foreign server... Could you, please, clarify about another (the first) part of my question? Why the server choose seq scan

Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)

2019-05-06 Thread Jeff Janes
On Mon, May 6, 2019 at 10:44 AM Vitaly Baranovsky wrote: > Hello all, > > I faced strange behavior of PostgreSQL during the query execution. > ... > Also, please, note, that SQL without WHERE clause has been set to the > foreign server: > " Remote SQL: SELECT primary_uuid FROM