explain -> how to optimize? - Mailing list pgsql-general

From will trillich
Subject explain -> how to optimize?
Date
Msg-id 20010307112434.A7383@mail.serensoft.com
Whole thread Raw
Responses Re: explain -> how to optimize?
List pgsql-general
here's an EXPLAIN on a VIEW which links a few tables:

=# explain SELECT * FROM RATING;

NOTICE:  QUERY PLAN:

Merge Join  (cost=11.18..11.51 rows=19 width=217)
  ->  Sort  (cost=9.98..9.98 rows=19 width=189)
        ->  Merge Join  (cost=9.24..9.58 rows=19 width=189)
              ->  Sort  (cost=8.04..8.04 rows=19 width=161)
                    ->  Hash Join  (cost=4.44..7.64 rows=19 width=161)
                          ->  Seq Scan on _rating r  (cost=0.00..1.42 rows=42 width=45)
                          ->  Hash  (cost=4.42..4.42 rows=8 width=116)
                                ->  Merge Join  (cost=4.14..4.42 rows=8 width=116)
                                      ->  Sort  (cost=2.63..2.63 rows=5 width=60)
                                            ->  Merge Join  (cost=2.38..2.57 rows=5 width=60)
                                                  ->  Sort  (cost=1.30..1.30 rows=11 width=32)
                                                        ->  Seq Scan on _topic t  (cost=0.00..1.11 rows=11 width=32)
                                                  ->  Sort  (cost=1.08..1.08 rows=4 width=28)
                                                        ->  Seq Scan on _edu e  (cost=0.00..1.04 rows=4 width=28)
                                      ->  Sort  (cost=1.52..1.52 rows=17 width=56)
                                            ->  Seq Scan on _course c  (cost=0.00..1.17 rows=17 width=56)
              ->  Sort  (cost=1.20..1.20 rows=8 width=28)
                    ->  Seq Scan on _who f  (cost=0.00..1.08 rows=8 width=28)
  ->  Sort  (cost=1.20..1.20 rows=8 width=28)
        ->  Seq Scan on _who s  (cost=0.00..1.08 rows=8 width=28)

EXPLAIN

okay, there's a ton of sorts and so forth in there that don't
seem to be needed; plus i'm sure i've got indexes on the
linked-to tables, so why the SEQ scans, i dunno.

how can i take this information and hunt down the slow stuff and
tweak it to perform more quickly?

--
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

pgsql-general by date:

Previous
From: Richard Poole
Date:
Subject: Re: ambiguous
Next
From: "Simon Crute"
Date:
Subject: How robust is postgresql ?