pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oleg Lebedev <olebedev@waterford.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgres SQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: won't drop the view
Date: Tue, 25 Dec 2001 19:49:48 -0700
Message-ID: <3C293ACB.4BEBA02F@waterford.org> (raw)
References: <web-530735@davinci.ethosmedia.com>
	<8922.1008638480@sss.pgh.pa.us>

Thanks everybody for your help.
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.
I hope this will help you improve your query optimizer.
thanks,

Oleg

Tom Lane wrote:

> "Josh Berkus" <josh@agliodbs.com> writes:
> > Damn.  I can only really help with the obvious things, and you've
> > covered most of those.  That view should take a long time, given the
> > complexity ... but a long time is 30-60 seconds, not 10 minutes.
>
> I'm guessing it's ye olde stupid-choice-of-plan kind of problem.
> Unless I missed it, we have not been shown the plan currently being
> used (no, the first four lines don't do it for me...)
>
> You could probably get back to the previous, not-so-slow plan choice
> by doing "DELETE FROM pg_statistic" to remove the data collected by
> VACUUM ANALYZE.  A comparison of the EXPLAIN output in that state
> vs. the EXPLAIN output in the analyzed state might be enlightening.
>
>                         regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

Attachments:

progress_report.txt (text/plain, 6.0K) download execution time ~ 15sec. NOTICE: QUERY PLAN: Subquery Scan progress_report (cost=14648.65..14648.65 rows=4 width=128) -> Sort (cost=14648.65..14648.65 rows=4 width=128) -> 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) -> Aggregate (cost=14553.17..14617.36 rows=367 width=112) -> Group (cost=14553.17..14562.34 rows=3668 width=112) -> Sort (cost=14553.17..14553.17 rows=3668 width=112) -> Subquery Scan stats (cost=13969.18..14336.00 rows=3668 width=112) -> Unique (cost=13969.18..14336.00 rows=3668 width=112) -> Sort (cost=13969.18..13969.18 rows=36682 width=112) -> Append (cost=1.31..9744.33 rows=36682 width=112) -> Subquery Scan *SELECT* 1 (cost=1.31..1154.05 rows=11459 width=56) -> Hash Join (cost=1.31..1154.05 rows=11459 width=56) -> Seq Scan on media (cost=0.00..407.59 rows=11459 width=36) -> Hash (cost=1.25..1.25 rows=25 width=20) -> Seq Scan on mediatypemap (cost=0.00..1.25 rows=25 width=20) -> Subquery Scan *SELECT* 2 (cost=1313.31..4930.60 rows=20704 width=80) -> Hash Join (cost=1313.31..4930.60 rows=20704 width=80) -> Hash Join (cost=1283.70..3513.64 rows=21196 width=64) -> Seq Scan on intsetmedia (cost=0.00..399.96 rows=21196 width=16) -> Hash (cost=1154.05..1154.05 rows=11459 width=48) -> Hash Join (cost=1.31..1154.05 rows=11459 width=48) -> Seq Scan on media (cost=0.00..407.59 rows=11459 width=28) -> Hash (cost=1.25..1.25 rows=25 width=20) -> Seq Scan on mediatypemap (cost=0.00..1.25 rows=25 width=20) -> Hash (cost=27.69..27.69 rows=769 width=16) -> Seq Scan on set (cost=0.00..27.69 rows=769 width=16) -> Subquery Scan *SELECT* 3 (cost=1469.06..3659.68 rows=4519 width=112) -> Hash Join (cost=1469.06..3659.68 rows=4519 width=112) -> Hash Join (cost=1467.74..3364.32 rows=4519 width=92) -> Hash Join (cost=689.81..1978.41 rows=4519 width=64) -> Hash Join (cost=585.40..1498.78 rows=9148 width=32) -> Seq Scan on dtrowmedia (cost=0.00..164.48 rows=9148 width=16) -> Hash (cost=306.99..306.99 rows=16799 width=16) -> Seq Scan on dtrow (cost=0.00..306.99 rows=16799 width=16) -> Hash (cost=102.55..102.55 rows=744 width=32) -> Hash Join (cost=6.62..102.55 rows=744 width=32) -> Seq Scan on dtcol (cost=0.00..32.06 rows=1506 width=16) -> Hash (cost=5.90..5.90 rows=290 width=16) -> Seq Scan on datatable (cost=0.00..5.90 rows=290 width=16) -> Hash (cost=407.59..407.59 rows=11459 width=28) -> Seq Scan on media (cost=0.00..407.59 rows=11459 width=28) -> Hash (cost=1.25..1.25 rows=25 width=20) -> Seq Scan on mediatypemap (cost=0.00..1.25 rows=25 width=20) EXPLAIN
progress_report_analyzed.txt (text/plain, 5.6K) download execution time ~ 12-13 mins. NOTICE: QUERY PLAN: Subquery Scan progress_report (cost=14687.00..14687.00 rows=2 width=128) -> Sort (cost=14687.00..14687.00 rows=2 width=128) -> 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) -> Aggregate (cost=14605.17..14671.27 rows=378 width=112) -> Group (cost=14605.17..14614.61 rows=3777 width=112) -> Sort (cost=14605.17..14605.17 rows=3777 width=112) -> Subquery Scan stats (cost=14003.05..14380.75 rows=3777 width=112) -> Unique (cost=14003.05..14380.75 rows=3777 width=112) -> Sort (cost=14003.05..14003.05 rows=37771 width=112) -> Append (cost=1.31..9627.85 rows=37771 width=112) -> Subquery Scan *SELECT* 1 (cost=1.31..1154.05 rows=11459 width=56) -> Hash Join (cost=1.31..1154.05 rows=11459 width=56) -> Seq Scan on media (cost=0.00..407.59 rows=11459 width=36) -> Hash (cost=1.25..1.25 rows=25 width=20) -> Seq Scan on mediatypemap (cost=0.00..1.25 rows=25 width=20) -> Subquery Scan *SELECT* 2 (cost=1313.31..4930.60 rows=21196 width=80) -> Hash Join (cost=1313.31..4930.60 rows=21196 width=80) -> Hash Join (cost=1283.70..3513.64 rows=21196 width=64) -> Seq Scan on intsetmedia (cost=0.00..399.96 rows=21196 width=16) -> Hash (cost=1154.05..1154.05 rows=11459 width=48) -> Hash Join (cost=1.31..1154.05 rows=11459 width=48) -> Seq Scan on media (cost=0.00..407.59 rows=11459 width=28) -> Hash (cost=1.25..1.25 rows=25 width=20) -> Seq Scan on mediatypemap (cost=0.00..1.25 rows=25 width=20) -> Hash (cost=27.69..27.69 rows=769 width=16) -> Seq Scan on set (cost=0.00..27.69 rows=769 width=16) -> Subquery Scan *SELECT* 3 (cost=1993.99..3543.20 rows=5116 width=112) -> Hash Join (cost=1993.99..3543.20 rows=5116 width=112) -> Hash Join (cost=1992.68..3209.05 rows=5116 width=92) -> Seq Scan on media (cost=0.00..407.59 rows=11459 width=28) -> Hash (cost=1979.89..1979.89 rows=5116 width=64) -> Hash Join (cost=690.05..1979.89 rows=5116 width=64) -> Hash Join (cost=585.40..1498.78 rows=9148 width=32) -> Seq Scan on dtrowmedia (cost=0.00..164.48 rows=9148 width=16) -> Hash (cost=306.99..306.99 rows=16799 width=16) -> Seq Scan on dtrow (cost=0.00..306.99 rows=16799 width=16) -> Hash (cost=102.55..102.55 rows=842 width=32) -> Hash Join (cost=6.62..102.55 rows=842 width=32) -> Seq Scan on dtcol (cost=0.00..32.06 rows=1506 width=16) -> Hash (cost=5.90..5.90 rows=290 width=16) -> Seq Scan on datatable (cost=0.00..5.90 rows=290 width=16) -> Hash (cost=1.25..1.25 rows=25 width=20) -> Seq Scan on mediatypemap (cost=0.00..1.25 rows=25 width=20) EXPLAIN

view thread (12+ messages)  latest in thread

Message-ID: <3C293ACB.4BEBA02F@waterford.org>
Permalink:  ../3C293ACB.4BEBA02F@waterford.org/
Also on:    postgresql.org/message-id/3C293ACB.4BEBA02F@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, tgl@sss.pgh.pa.us
  Subject: Re: won't drop the view
  In-Reply-To: <3C293ACB.4BEBA02F@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