Question about cost-calculation

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Question about cost-calculation
Дата
Msg-id 20080602100529.GD25294@a-kretschmer.de
обсуждение исходный текст
Ответы Re: Question about cost-calculation  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi,

according the doc
(http://www.postgresql.org/docs/8.3/interactive/runtime-config-query.html#GUC-CPU-OPERATOR-COST),

Quote:
Sets the planner's estimate of the cost of processing each operator or function executed during a query.


i expected for a 1000 row test-table a cost per function of 2.5
(cpu_operator_cost = 0.0025), but i got 5.



First, a full table scan:

test=*# explain analyse select i from s_test;
                                              QUERY PLAN
-------------------------------------------------------------------------------------------------------
 Seq Scan on s_test  (cost=0.00..15.00 rows=1000 width=4) (actual time=0.013..2.315 rows=1000 loops=1)
 Total runtime: 4.232 ms
(2 rows)


cost=15.

Now, the same query but with one or two functions on a particular column:


test=*# explain analyse select i, cos(i) from s_test;
                                              QUERY PLAN
-------------------------------------------------------------------------------------------------------
 Seq Scan on s_test  (cost=0.00..20.00 rows=1000 width=4) (actual time=0.026..3.043 rows=1000 loops=1)
 Total runtime: 5.017 ms
(2 rows)

test=*# explain analyse select i, cos(i), md5(i) from s_test;
                                              QUERY PLAN
-------------------------------------------------------------------------------------------------------
 Seq Scan on s_test  (cost=0.00..25.00 rows=1000 width=4) (actual time=0.040..5.414 rows=1000 loops=1)
 Total runtime: 7.444 ms
(2 rows)

cost increased by 5 per function-call, why, why not 2.5?


Version: 8.1


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

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

Предыдущее
От: "Andrej Ricnik-Bay"
Дата:
Сообщение: Re: Bottom Posting
Следующее
От: "Brian A. Seklecki"
Дата:
Сообщение: Re: [Xen-users] SNMP AgentX subagent for Xen