Re: BUG #14845: postgres_fdw and mysql_fdw can cause crash of instance

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Josef Machytka <josef(dot)machytka(at)gmail(dot)com>, Fabrízio Mello <fabriziomello(at)gmail(dot)com>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14845: postgres_fdw and mysql_fdw can cause crash of instance
Date: 2017-10-07 01:46:37
Message-ID: CAMkU=1yn=feWCzANUUG3okswzBM2EpFHcwv_R1Pii8HWKDaOyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Oct 6, 2017 at 10:01 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Josef Machytka <josef(dot)machytka(at)gmail(dot)com> writes:
> > In this case which went wrong I used postgres_fdw to compare data on
> local
> > and remote database using "select all from remote except select all from
> > local".
>
> I think my theory B probably applies then: without use_remote_estimate,
> the planner would not guess that the remote table is huge, and that could
> well allow it to pick a hashed EXCEPT implementation --- which will then
> try to collect the entire remote table into an in-memory hash table.
>

Unfortunately, use_remote_estimate won't help for this particular case.
While it gets the estimate for the number of rows from the remote estimate,
HashSetOp doesn't care about estimated number of rows, only estimated
number of distinct rows. And use_remote_estimate doesn't provide that, so
it falls back on assuming (I think) 200 distinct rows.

What could help is running 'analyze' locally against the foreign table.
That can cause other problems, though.

Cheers,

Jeff

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2017-10-07 02:26:33 Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document
Previous Message Andres Freund 2017-10-07 01:22:52 Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document