How to read a query plan?

From: elwood(at)agouros(dot)de (Konstantinos Agouros)
To: pgsql-general(at)postgresql(dot)org
Subject: How to read a query plan?
Date: 2001-04-18 08:40:03
Message-ID: elwood.987583040@news.agouros.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

since I am still working on my quite big database and the last time a simple
index saved my life I would like to understand query plans. Here are two
one without and one with index I see different numbers, but would like to know
what they mean:
logs=> explain select distinct on (url) url, category, action from websenseflat where webhost='dir.yahoo.com' and datum >='1-26-2001' and datum < '1-27-2001';
NOTICE: QUERY PLAN:

Unique (cost=0.01..0.01 rows=1 width=36)
-> Sort (cost=0.01..0.01 rows=1 width=36)
-> Seq Scan on websenseflat (cost=0.00..0.00 rows=1 width=36)

EXPLAIN

after this I created an index on the field webhost, now the query plan says:

NOTICE: QUERY PLAN:

Unique (cost=19690.08..19690.22 rows=5 width=36)
-> Sort (cost=19690.08..19690.08 rows=53 width=36)
-> Index Scan using wsflwebhost on websenseflat (cost=0.00..19688.55 rows=53 width=36)

EXPLAIN

Could someone give me an interpretation (or a URL that explains this)?

Thanks,

Konstantin
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood(at)agouros(dot)de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres

Responses

Browse pgsql-general by date

  From Date Subject
Next Message newsreader 2001-04-18 09:57:40 watch your DBI scripts if you are upgrading to 7.1
Previous Message DaVinci 2001-04-18 08:07:16 Passing a row (NEW) as function argument