From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Julien Rouhaud <julien.rouhaud@dalibo.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Stefan Huehner <stefan@huehner.org>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: pg9.6 segfault using simple query (related to use fk for join estimates)
Date: Tue, 3 May 2016 16:17:05 +0200
Message-ID: <cede673a-ad64-ed27-8c4d-1186f4e22dae@2ndquadrant.com> (raw)
In-Reply-To: <CA+TgmoY61W0MxjErY6d9x=L1fgkgA8DWXyXb9SQmviFstBCZxg@mail.gmail.com>
References: <20160429102531.GA13701@huehner.biz>
<CAB7nPqRj2EsGdoNESsWVC-RHV918Scd1xQEcYt3dK9Rs5RpuAQ@mail.gmail.com>
<572384D7.1020602@dalibo.com>
<17639.1461945908@sss.pgh.pa.us>
<57238E64.8010702@dalibo.com>
<22731.1462037712@sss.pgh.pa.us>
<CA+TgmoY61W0MxjErY6d9x=L1fgkgA8DWXyXb9SQmviFstBCZxg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Hi,
On 05/02/2016 09:18 PM, Robert Haas wrote:
> On Sat, Apr 30, 2016 at 1:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Julien Rouhaud <julien.rouhaud@dalibo.com> writes:
>>> On 29/04/2016 18:05, Tom Lane wrote:
>>>> Julien Rouhaud <julien.rouhaud@dalibo.com> writes:
>>>>> The segfault is caused by quals_match_foreign_key() calling get_leftop()
>>>>> and get_rightop() on a ScalarArrayOpExpr node.
>>>>>
>>>>> I'm not sure that assuming this compatibility is the right way to fix
>>>>> this though.
>>
>>>> It certainly isn't.
>>
>>> Agreed. New attached patch handles explicitly each node tag.
>>
>> No, this is completely nuts. The problem is that quals_match_foreign_key
>> is simply assuming that every clause in the list it's given is an OpExpr,
>> which is quite wrong. It should just ignore non-OpExpr quals, since it
>> cannot do anything useful with them anyway. There's a comment claiming
>> that non-OpExpr quals were already rejected:
>>
>> * Here since 'usefulquals' only contains bitmap indexes for quals
>> * of type "var op var" we can safely skip checking this.
>>
>> but that doesn't appear to have anything to do with current reality.
>>
>> While this in itself is about a two-line fix, after reviewing
>> 137805f89acb3611 I'm pretty unhappy that it got committed at all.
>> I think this obvious bug is a good sign that it wasn't ready.
>> Other unfinished aspects like invention of an undocumented GUC
>> don't leave a good impression either.
>>
>> Moreover, it looks to me like this will add quite a lot of overhead,
>> probably far more than is justified, because clauselist_join_selectivity
>> is basically O(N^2) in the relation-footprint of the current join --- and
>> not with a real small multiplier, either, as the functions it calls
>> contain about four levels of nested loops themselves. Maybe that's
>> unmeasurable on trivial test cases but it's going to be disastrous in
>> large queries, or for relations with large numbers of foreign keys.
>>
>> I think this should be reverted and pushed out to 9.7 development.
>> It needs a significant amount of rewriting to fix the performance
>> issue, and now's not the time to be doing that.
>
> If this gets reverted, then probably
> 015e88942aa50f0d419ddac00e63bb06d6e62e86 should also be reverted.
Probably. I think the code is fine / correct, but as the FK estimation
patch was the only user, there's not much point in keeping it if that
gets reverted.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tomas.vondra@2ndquadrant.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, julien.rouhaud@dalibo.com, simon@2ndquadrant.com, michael.paquier@gmail.com, stefan@huehner.org
Subject: Re: pg9.6 segfault using simple query (related to use fk for join estimates)
In-Reply-To: <cede673a-ad64-ed27-8c4d-1186f4e22dae@2ndquadrant.com>
References: <20160429102531.GA13701@huehner.biz> <CAB7nPqRj2EsGdoNESsWVC-RHV918Scd1xQEcYt3dK9Rs5RpuAQ@mail.gmail.com> <572384D7.1020602@dalibo.com> <17639.1461945908@sss.pgh.pa.us> <57238E64.8010702@dalibo.com> <22731.1462037712@sss.pgh.pa.us> <CA+TgmoY61W0MxjErY6d9x=L1fgkgA8DWXyXb9SQmviFstBCZxg@mail.gmail.com> <cede673a-ad64-ed27-8c4d-1186f4e22dae@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox