Search Postgresql Archives

Question about cost-calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux