Re: Encouraging multi-table join order - Mailing list pgsql-performance

From Dan Harris
Subject Re: Encouraging multi-table join order
Date
Msg-id 443C18AA.3000500@drivefaster.net
Whole thread Raw
In response to Re: Encouraging multi-table join order  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Encouraging multi-table join order
List pgsql-performance
Tom Lane wrote:
> <SNIP>
> So it's estimating 5775 cost units per probe into eventactivity, which
> is pretty high --- it must think that a lot of rows will be retrieved by
> the index (way more than the 20 or so it thinks will get past the filter
> condition).

>  What does the pg_stats entry for eventactivity.incidentid
> contain?
select * from pg_stats where tablename = 'eventactivity' and
attname='incidentid';
 schemaname |   tablename   |  attname   | null_frac | avg_width |
n_distinct |
most_common_vals
|
most_common_freqs
|
histogram_bounds                                                      |
correlation

------------+---------------+------------+-----------+-----------+------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+-------------
 public     | eventactivity | incidentid |         0 |        14 |
8157 |
{P043190299,P051560740,P052581036,P052830218,P053100679,P053190889,P060370845,P042070391,P042690319,P043290117}
|
{0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00133333,0.00133333,0.00133333}
|

{P022140319,P030471058,P033090308,P041961082,P042910689,P050311006,P051350254,P052261148,P053270945,P060240316,P061000287}

|    0.241737

>   It might be worth increasing the statistics target for that
> column to try to get a better estimate.
>
How high should I set this?  I read the default is 10, but I'm not sure
if doubling this would make a difference or if I should be doing a much
larger number. There's approx 45 million rows in the table, if that matters.


Thanks again,
Dan

pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: FOREIGN KEYS vs PERFORMANCE
Next
From: "Merlin Moncure"
Date:
Subject: Re: Stored Procedure Performance