Re: Understanding EXPLAIN

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: Understanding EXPLAIN
Дата
Msg-id 20120203082247.GA12820@tux
обсуждение исходный текст
Ответ на Understanding EXPLAIN  (Robert Lichtenberger <r.lichtenberger@synedra.com>)
Список pgsql-general
Robert Lichtenberger <r.lichtenberger@synedra.com> wrote:

> I am trying to fully understand, how costs for queries are computed.
> Taking the following example:
>
> CREATE TABLE test (name varchar(250) primary key) ;
> INSERT INTO test (name) VALUES(generate_series(1, 1000)::text) ;
> ANALYZE test ;
> EXPLAIN SELECT * FROM test WHERE name = '4' ;
>
> I am getting the output:
> Index Scan using test_pkey on test  (cost=0.00..8.27 rows=1 width=3)
>   Index Cond: ((name)::text = '4'::text)
>
> The server has default cost parameters
>
> The value I want to understand is 8.27. From reading the book
> "PostgreSQL 9.0 High Performance" I know, that we have one index page
> read (random page read, cost=4.0) and one database row read (random page
> read, cost=4.0) which comes up to a total of 8.0. But where are the
> missing 0.27 from?
>
> If I modify the example to insert 10,000 rows, the cost stays the same.
> Only if I go for 100,000 rows will the computed cost increase to 8.29.
>
> Can anybody enlighten me, please ;-).

There are some other costs, in your case cpu_tuple_cost and
cpu_index_tuple_cost.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Understanding EXPLAIN
Следующее
От: garry
Дата:
Сообщение: last entry per person