pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: David Rowley <david.rowley@2ndquadrant.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: Fri, 6 May 2016 01:00:59 +0200
Message-ID: <4cf45f48-5e92-903b-9f29-af5215fdf715@2ndquadrant.com> (raw)
In-Reply-To: <CAKJS1f8iHbN4KC+=BK=M_UTeCsTsfjqQWBZjN3w9NxqKKfL7dw@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>
	<8344835e-18af-9d40-aed7-bd2261be9162@2ndquadrant.com>
	<CAKJS1f9VMZGfPCDWeuLoD1rgvTr5JzGLh7vc4YWQCSDrmRCKbQ@mail.gmail.com>
	<CAKJS1f-Eqa23_K1x_jpgVn97TigcTm7RucuD=tpSEpGpLx4ULw@mail.gmail.com>
	<16807.1462388069@sss.pgh.pa.us>
	<CAKJS1f-5WjfJLu0Y4hnfR01ZCBsd5FrDQ7kz5ayAt1t7DZ5vLQ@mail.gmail.com>
	<CAKJS1f8iHbN4KC+=BK=M_UTeCsTsfjqQWBZjN3w9NxqKKfL7dw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hi,

On 05/05/2016 04:48 PM, David Rowley wrote:
> On 5 May 2016 at 16:04, David Rowley <david.rowley@2ndquadrant.com> wrote:
>> I've started making some improvements to this, but need to talk to
>> Tomas. It's currently in the middle of his night, but will try to
>> catch him in his morning to discuss this with him.
>
> Ok, so I spoke to Tomas about this briefly, and he's asked me to
> send in this patch. He didn't get time to look over it due to some
> other commitments he has today.
>

Thanks!

 >
> I do personally feel that if the attached is not good enough, or not
> very close to good enough then probably the best course of action is
> to revert the whole thing. I'd much rather have this out than to
> feel some responsibility for someone's performance problems with
> this feature.
 >

I share this opinion. If the approach proposed here is deemed not good 
enough, then +1 to revert.

I think we can further limit the impact by ignoring foreign keys on a 
single column, because the primary goal of the patch is improving 
estimates with multi-column FKs (and matching joins). I'd argue that 99% 
of the FKs in practice is single-column ones, but sure - if you have a 
database with many multi-column FKs this won't help.

I think it's also important to point out that whatever solution we 
choose, it should probably allow us to relax some of the restrictions in 
the future. For example, with a FK on 3 columns, the current patch only 
handles a "full match" joins, with conditions on all three columns. But 
it may be possible to also improve estimates on just two columns - the 
current patch does not do that, as that needs definitely further more 
thought and discussion.

 >
> But I also do feel that the patch allows a solution to a big problem
> that we currently have with PostgreSQL, which there's any easy
> workarounds for... that's multi-column join estimates.
>

In a sense, yes. FKs allow us to improve estimates for a fairly narrow 
case of multi-column estimates - joins matching multi-column FKs. And 
for this (not entirely narrow) case they are actually more accurate and 
way cheaper than e.g. histograms or MCV lists (at least in the 
multi-column case).

FWIW the current multivariate stats patch does not even try to mess with 
joins, as it's quite complicated in the multi-column case.

>
> In the attached I've left the GUC remaining. The reason for the GUC
> is for testing purposes and it should be removed before release. It
> should likely be documented though, even if we're planning to remove
> it later. I've not gotten around to that in this patch though.
>

Yes, removal of the GUC should go to the Open Items list.


I'd also like to make it clear that all the shitty parts of the patch 
are my fault, not David's. His name is on the patch as he provided a lot 
of useful ideas, pieces of code and feedback in general. But it was up 
to me to craft the final patch - and I clearly failed to do so. I think 
David still feels responsible for the patch as he made a lot of effort 
to salvage it over the last few days, so I'd like to set the record 
straight.


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



view thread (50+ messages)  latest in thread

Message-ID: <4cf45f48-5e92-903b-9f29-af5215fdf715@2ndquadrant.com>
Permalink:  ../4cf45f48-5e92-903b-9f29-af5215fdf715@2ndquadrant.com/
Also on:    postgresql.org/message-id/4cf45f48-5e92-903b-9f29-af5215fdf715@2ndquadrant.com

 · 

reply

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, david.rowley@2ndquadrant.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: <4cf45f48-5e92-903b-9f29-af5215fdf715@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> <8344835e-18af-9d40-aed7-bd2261be9162@2ndquadrant.com> <CAKJS1f9VMZGfPCDWeuLoD1rgvTr5JzGLh7vc4YWQCSDrmRCKbQ@mail.gmail.com> <CAKJS1f-Eqa23_K1x_jpgVn97TigcTm7RucuD=tpSEpGpLx4ULw@mail.gmail.com> <16807.1462388069@sss.pgh.pa.us> <CAKJS1f-5WjfJLu0Y4hnfR01ZCBsd5FrDQ7kz5ayAt1t7DZ5vLQ@mail.gmail.com> <CAKJS1f8iHbN4KC+=BK=M_UTeCsTsfjqQWBZjN3w9NxqKKfL7dw@mail.gmail.com> <4cf45f48-5e92-903b-9f29-af5215fdf715@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