Re: won't drop the view

Поиск
Список
Период
Сортировка
Искать
От
Oleg Lebedev
Тема
Re: won't drop the view
Дата
Msg-id
3C293ACB.4BEBA02F@waterford.org
Список
Дерево обсуждения
Re: won't drop the view Oleg Lebedev <olebedev@waterford.org>
Re: won't drop the view Tom Lane <tgl@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"  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
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
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
В списке pgsql-sql по дате отправления
От: Juan Riera
Дата:
Сообщение: Re: PostgreSQL SELECT error
От: Tom Lane
Дата:
Сообщение: Re: won't drop the view
FAQ