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

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Vitaly Baranovsky <barvetalforums(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)
Date: 2019-05-06 17:17:36
Message-ID: CAMkU=1yeu2RL6uEzETDNzoCkXQJAjmuP+mQWGLJ2Kv2ES3avNg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, May 6, 2019 at 11:53 AM Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:

> On Mon, May 6, 2019 at 11:38 AM Vitaly Baranovsky <
> barvetalforums(at)gmail(dot)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 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 instead of pk key index
>> only scan for the local table?
>>
>> Thank you
>>
>>
> Aren't those the same thing? The foreign server can't use the where
> clause, if it doesn't get sent.
>

Nevermind. When you said local table, I had some tunnel vision and was
thinking of the foreign table as viewed from the perspective of the foreign
server (to which it is local), not the actual local table. That too is
"fixed" in the same commit to the 12dev branch as the other issue is:

commit 4be058fe9ec5e630239b656af21fc083371f30ed
Date: Mon Jan 28 17:54:10 2019 -0500

In the planner, replace an empty FROM clause with a dummy RTE.

My tests are all done with empty, unanalyzed tables as I just took you DDL
without inventing my own DML, so may be different than what what you were
seeing with your populated tables.

Cheers,

Jeff

>

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Steven Winfield 2019-05-07 16:14:43 GCC 8.3.0 vs. 9.0.1
Previous Message Vitaly Baranovsky 2019-05-06 16:36:56 Re: PostgreSQL optimizer use seq scan instead of pkey index only scan (in queries with postgres_fdw)