Re: Stats for multi-column indexes - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Stats for multi-column indexes
Date
Msg-id 1174412816.23455.521.camel@dogma.v10.wvs
Whole thread Raw
In response to Re: Stats for multi-column indexes  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
On Tue, 2007-03-20 at 18:12 +0100, Josh Berkus wrote:
> Tom,
> 
> > Actually, I think you don't particularly need stats for that in most
> > cases --- if the planner simply took note that the FK relationship
> > exists, it would know that each row of the FK side joins to exactly
> > one row of the PK side, which in typical cases is sufficient.
> 
> Is it?  What about the other direction?  Currently, doesn't the planner 
> assume that the rowcount relationship is 1 to ( child total rows / 
> parent total rows) ?  That's ok for tables with relatively even 
> distribution, but not for skewed ones.
> 

In theory, the PK constrains the available values of the FK, but doesn't
provide any additional information about the relationship between the
columns. 

However, in practice there is limited space to store MCVs and limited
accuracy to n_distinct. So there may be a reason to store more
information, but I don't know what we'd store. Do we have reports of bad
estimates by the planner in this situation?

Regards,Jeff Davis



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Buildfarm feature request: some way to track/classify failures
Next
From: Tom Lane
Date:
Subject: Re: Stats for multi-column indexes