pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: Julien Rouhaud <julien.rouhaud@dalibo.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: Mon, 06 Jun 2016 13:44:51 -0400
Message-ID: <26676.1465235091@sss.pgh.pa.us> (raw)
In-Reply-To: <2a8adc56-6eb1-123e-8914-0cf025797262@2ndquadrant.com>
References: <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>
	<CA+TgmobPqrAVXOBMHTcpDq8hX7gCzcVhoUvC8s9V=d09+bt30w@mail.gmail.com>
	<20160529053601.GE496776@tornado.leadboat.com>
	<20160602012954.GA619629@tornado.leadboat.com>
	<CA+TgmoavPp9Xdo-DG1v8W0o+0GJwtevMqcEdh6WoT39ggv0oSg@mail.gmail.com>
	<28109.1465064127@sss.pgh.pa.us>
	<039fca3d-890a-d09a-e0df-e045187eb69e@2ndquadrant.com>
	<23385.1465229755@sss.pgh.pa.us>
	<24068.1465230882@sss.pgh.pa.us>
	<2a8adc56-6eb1-123e-8914-0cf025797262@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> When it comes to improving multiple (multi-column) foreign keys, I think 
> it may get way more complicated that it might seem. What if the foreign 
> keys overlap, for example? Or what if the keys go in opposite directions 
> (cycle). And so on ...

I think you can group all FKs referencing the same table and discard
all their matched join clauses in favor of a single 1/N estimate
(and when I say "discard", that means you don't match those clauses
against later FKs, which should take care of the reciprocal-FK issue).
This is clearly correct if no nulls are involved.  We need to make some
estimate of how much to de-rate that figure for nulls, but I don't see
that it's any harder than what's already required for a single multicol
FK.

			regards, tom lane


-- 
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: <26676.1465235091@sss.pgh.pa.us>
Permalink:  ../26676.1465235091@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26676.1465235091@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, tomas.vondra@2ndquadrant.com, robertmhaas@gmail.com, noah@leadboat.com, simon@2ndquadrant.com, david.rowley@2ndquadrant.com, julien.rouhaud@dalibo.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: <26676.1465235091@sss.pgh.pa.us>
  References: <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> <CA+TgmobPqrAVXOBMHTcpDq8hX7gCzcVhoUvC8s9V=d09+bt30w@mail.gmail.com> <20160529053601.GE496776@tornado.leadboat.com> <20160602012954.GA619629@tornado.leadboat.com> <CA+TgmoavPp9Xdo-DG1v8W0o+0GJwtevMqcEdh6WoT39ggv0oSg@mail.gmail.com> <28109.1465064127@sss.pgh.pa.us> <039fca3d-890a-d09a-e0df-e045187eb69e@2ndquadrant.com> <23385.1465229755@sss.pgh.pa.us> <24068.1465230882@sss.pgh.pa.us> <2a8adc56-6eb1-123e-8914-0cf025797262@2ndquadrant.com> <26676.1465235091@sss.pgh.pa.us>

* 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