explain, planner and more.. - Mailing list pgsql-general

From Svenne Krap
Subject explain, planner and more..
Date
Msg-id vj7jntk2eeahirm9l9pg4d4n1v9bj4ic19@4ax.com
Whole thread Raw
Responses Re: explain, planner and more..
List pgsql-general
Hi,

how has the following to be read.. (ie. what is the total cost of the
query)... 4.05, 5.88 or ?

Why does the planner choose not to use numberdomain_pkey as index on
numberdomain ?

The table layout is quite bad (due to a lot of last minute-changes)

<snip>
# explain select c.*, (select count(*) from numberservice ns where
ns.customerid=c.customerid and (exists (select * from numbermail nm
where nm.domainnr = ns.domainnr) or exists(select * from numberdomain
nd where nd.domainnr=ns.domainnr))) as amount from customer c where
c.status=0;
NOTICE:  QUERY PLAN:

Seq Scan on customer c  (cost=0.00..4.05 rows=46 width=200)
  SubPlan
    ->  Aggregate  (cost=5.88..5.88 rows=1 width=0)
          ->  Index Scan using numberservice_customerid_ix on
numberservice ns  (cost=0.00..5.88 rows=1 width=0)
                SubPlan
                  ->  Index Scan using numbermail_pkey on numbermail
nm  (cost=0.00..2.01 rows=1 width=47)
                  ->  Seq Scan on numberdomain nd  (cost=0.00..1.85
rows=1 width=31)

EXPLAIN
--
Mail usenet@krap.dk - svenne@krap.dk - PGP key id : 0xDF484022
ICQ: 5434480 - http://www.krap.dk - http://www.krap.net
PGP Key http://keys.pgp.dk:11371/pks/lookup?op=get&search=0xDF484022

pgsql-general by date:

Previous
From: Jochem van Dieten
Date:
Subject: Re: PostgresQL equivalent of NOCOUNT
Next
From: Joseph Shraibman
Date:
Subject: Re: LARGE db dump/restore for upgrade question