pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Odd problem with performance in duplicate database
Date: Mon, 11 Aug 2003 19:59:36 -0400
Message-ID: <27328.1060646376@sss.pgh.pa.us> (raw)
In-Reply-To: <200308111651.01597.josh@agliodbs.com>
References: <ENEDIMLCODBHILEONAOMAEBNCEAA.pdarley@kinesis-cem.com>
	<200308111559.09924.josh@agliodbs.com>
	<26934.1060644171@sss.pgh.pa.us>
	<200308111651.01597.josh@agliodbs.com>

Josh Berkus <josh@agliodbs.com> writes:
> My reading is that the case is "borderline";

Well, clearly the planner is flipping to a much less desirable plan, but
the core estimation error is not borderline by my standards.  In the
live DB we have this subplan:

->  Nested Loop  (cost=0.00..7.41 rows=1 width=12) (actual time=0.01..0.02 rows=1 loops=856)
    ->  Index Scan using trial_groups_pkey on trial_groups  (cost=0.00..3.49 rows=1 width=4) (actual time=0.01..0.01 rows=0 loops=856)
    ->  Index Scan using idx_cases_tgroup on cases  (cost=0.00..3.92 rows=1 width=8) (actual time=0.02..0.04 rows=4 loops=133)

In the test DB, the identical subplan is estimated at:

->  Nested Loop  (cost=0.00..81.53 rows=887 width=12) (actual time=0.03..0.04 rows=1 loops=855)
    ->  Index Scan using trial_groups_pkey on trial_groups  (cost=0.00..3.49 rows=1 width=4) (actual time=0.02..0.02 rows=0 loops=855)
    ->  Index Scan using idx_cases_tgroup on cases  (cost=0.00..77.77 rows=43 width=8) (actual time=0.03..0.07 rows=6 loops=133)

and that factor of 887 error in the output rows estimate is what's
driving all the outer plan steps to make bad choices.

The "trial_groups_pkey" estimate is the same in both databases,
so it's presumably a problem with estimating the number of
matches to a "trial_groups" row that will be found in "cases".
This is dependent on the pg_stats entries for the relevant
columns, which I'm still hoping to see ...

			regards, tom lane



view thread (14+ messages)  latest in thread

Message-ID: <27328.1060646376@sss.pgh.pa.us>
Permalink:  ../27328.1060646376@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27328.1060646376@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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com
  Subject: Re: Odd problem with performance in duplicate database
  In-Reply-To: <27328.1060646376@sss.pgh.pa.us>
  References: <ENEDIMLCODBHILEONAOMAEBNCEAA.pdarley@kinesis-cem.com> <200308111559.09924.josh@agliodbs.com> <26934.1060644171@sss.pgh.pa.us> <200308111651.01597.josh@agliodbs.com> <27328.1060646376@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