Search Postgresql Archives

Re: Numeric performances

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

 



Hmmm ...

It sounds quite strange to me that numeric is faster than bigint.

Even if bigint didn't get hw support in the CPU it should have been
faster that numeric as it should be mapped in 2 32-bits integers.

Numeric algorithms should be linear (according to the number of digits) in
complexity when compared to float, float8, integer and bigint (that should be
constant in my mind).

Nonetheless the suggested "fast test" makes some sense in my mind.

On Monday 04 June 2007 12:06:47 PFC wrote:
> >> It is.  But why do you care?  You either have the correctness that
> >> NUMERIC gives, or you don't.
> >
> > I suspect it's still useful to know what order of magnitude slower it
> > is. After all if it is 1000x slower (not saying it is), some people may
> > decide it's not worth it or roll their own.
> >
> > Any hints/gotchas for/when doing such performance tests?
>
> forum_bench=> CREATE TEMPORARY TABLE test AS SELECT a::FLOAT AS f,
> a::NUMERIC AS n, a::INTEGER AS i, a::BIGINT AS b FROM
> generate_series( 1,100000 ) AS a;
> SELECT
> Temps : 1169,125 ms
>
> forum_bench=> SELECT sum(i) FROM test;
> Temps : 46,589 ms
>
> forum_bench=> SELECT sum(b) FROM test;
> Temps : 157,018 ms
>
> forum_bench=> SELECT sum(f) FROM test;
> Temps : 63,865 ms
>
> forum_bench=> SELECT sum(n) FROM test;
> Temps : 124,816 ms
>
> SELECT * FROM test ORDER BY i LIMIT 1; SELECT * FROM test ORDER BY b LIMIT
> 1; SELECT * FROM test ORDER BY f LIMIT 1; SELECT * FROM test ORDER BY n
> LIMIT 1;
> Temps : 68,996 ms
> Temps : 68,917 ms
> Temps : 62,321 ms
> Temps : 71,880 ms
>
> BEGIN; CREATE INDEX test_i ON test(i); CREATE INDEX test_b ON test(b);
> CREATE INDEX test_f ON test(f); CREATE INDEX test_n ON test(n); ROLLBACK;
> CREATE INDEX
> Temps : 102,901 ms
> CREATE INDEX
> Temps : 123,406 ms
> CREATE INDEX
> Temps : 105,255 ms
> CREATE INDEX
> Temps : 134,468 ms


-- 
Vincenzo Romano
--
Maybe Computer will never become as intelligent as Humans.
For sure they won't ever become so stupid. [VR-1988]


[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