pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oleg Lebedev <olebedev@waterford.org>
Cc: Postgres SQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: won't drop the view
Date: Wed, 26 Dec 2001 12:40:01 -0700
Message-ID: <3C2A2791.830BE5F1@waterford.org> (raw)
References: <web-530735@davinci.ethosmedia.com>
	<8922.1008638480@sss.pgh.pa.us>
	<3C293ACB.4BEBA02F@waterford.org>
	<20130.1009385674@sss.pgh.pa.us>

You are right Tom,
(SELECT ...
        FROM activity
        WHERE   activity.productcode ~ '^m3') acts
yeilds 235 rows, with a total of 240 rows in activity table. I wonder why EXPLAIN estimates only 1
row? Are there any online docs on how the planner works?
BTW, I would like to buy a book that would help me tune up postgres performance. Which book would
you suggest?
Thanks,

Oleg

Tom Lane wrote:

> Oleg Lebedev <olebedev@waterford.org> writes:
> > Deleting from pg_statistic restored view performance to the way it was
> > before I ran vacuum analyze.
> > Below I attach two files that contain explain statistics for the view before
> > (progress_report.txt) and after (progress_report_analyzed.txt) I ran vacuum
> > analyze. The first one takes about 15 secs. to complete, the second one
> > takes 12-13 minutes to complete.
>
> Looks like the issue is the number of rows estimated to be obtained from
> the "activity" table:
>
> good plan:
>
> >         ->  Merge Join  (cost=14644.00..14648.62 rows=4 width=128)
> >               ->  Sort  (cost=11.02..11.02 rows=2 width=48)
> >                     ->  Seq Scan on activity  (cost=0.00..11.00 rows=2 width=48)
> >               ->  Sort  (cost=14632.99..14632.99 rows=367 width=112)
> >                     ->  Subquery Scan media_acts  (cost=14553.17..14617.36 rows=367 width=112)
>
> bad plan:
>
> >         ->  Nested Loop  (cost=14605.17..14686.99 rows=2 width=128)
> >               ->  Seq Scan on activity  (cost=0.00..11.00 rows=1 width=48)
> >               ->  Subquery Scan media_acts  (cost=14605.17..14671.27 rows=378 width=112)
>
> The plans for media_acts look about the same, so I have to guess that
> activity actually yields 50 or so rows, not just one.  That doesn't
> hurt the mergejoin too much, but it is a killer for the nestloop.
>
> You showed the query as
>  (SELECT ...
>         FROM activity
>         WHERE   activity.productcode ~ '^m3') acts
> How many rows actually match activity.productcode ~ '^m3' ?  How many
> rows altogether in activity?
>
>                         regards, tom lane




view thread (12+ messages)  latest in thread

Message-ID: <3C2A2791.830BE5F1@waterford.org>
Permalink:  ../3C2A2791.830BE5F1@waterford.org/
Also on:    postgresql.org/message-id/3C2A2791.830BE5F1@waterford.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: olebedev@waterford.org
  Subject: Re: won't drop the view
  In-Reply-To: <3C2A2791.830BE5F1@waterford.org>

* 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