Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Numeric performances


  • From: PFC <lists(at)peufeu(dot)com>
  • To: "Vincenzo Romano" <vincenzo(dot)romano(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
  • Subject: Re: Numeric performances
  • Date: Mon, 04 Jun 2007 13:17:49 +0200
  • Message-id: <op.ttd9nzwccigqcu@apollo13> <text/plain>


	This is a 32 bit CPU by the way.

	Consider this :

- There are 100K rows
- The CPU executes about 3 billion instructions per second if everything is optimum
- "SELECT sum(n) FROM test", takes, say 60 ms

	This gives about 1800 CPU ops per row.
	A Float addition versus an Int addition is a drop in the sea.

I believe the marked difference between Floats/Ints (faster) and Numeric/Bigint (slower) comes from being passed by value or by pointers.

A single access which misses the CPU cache and has to go fetch data from the real RAM spends a lot more cycles than the simple loops in a NUMERIC addition which will hit L1 cache. Nowadays cache access patterns matter more than how many actual CPU instructions are executed...

forum_bench=> SELECT sum(i) FROM test;
Temps : 46,589 ms
forum_bench=> SELECT sum(f) FROM test;
Temps : 63,865 ms

forum_bench=> SELECT sum(b) FROM test;
Temps : 157,018 ms
forum_bench=> SELECT sum(n) FROM test;
Temps : 124,816 ms



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group