Prev: Plans for 9.1, Grouping Sets, disablingmultiqueries, contrib module for string, plpgpsm, preload dictionaries
Next: [HACKERS] [Feature request] variable declaration of anonymous composite data type in PL/pgSQL
From: Yeb Havinga on 3 Mar 2010 05:57 Pavel Stehule wrote: > 2010/3/3 Yeb Havinga <yebhavinga(a)gmail.com>: > >> Theo Schlossnagle wrote: >> >>> I didn't look deeply at the postgres internals to see if there was a way >>> to do double -> numeric and integer-types -> numeric without intermediary >>> string format. If that sort of thing is easy to leverage, I'd be happy to >>> share the code. >>> >>> >> I think your code could be valuable for postgres on the fact alone that it >> is almost twice as fast, and probably easy to integrate and unit test. We >> make heavy use of the numeric data type, so I'm very interested! >> > > I did some test and numeric->double is about 5% faster than > numeric->string->double (on my PC) > numeric_to_double_no_overflow() also uses string as intermediate format. Theo's conversions are the converse, from double to numeric, and do not use string as intermediate format (if I understand it correct). (where float8_numeric http://doxygen.postgresql.org/backend_2utils_2adt_2numeric_8c.html#2de7f65c8de4b65dad441e77ea1bf402 does) regards Yeb Havinga -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Pavel Stehule on 3 Mar 2010 06:02 2010/3/3 Yeb Havinga <yebhavinga(a)gmail.com>: > Pavel Stehule wrote: >> >> 2010/3/3 Yeb Havinga <yebhavinga(a)gmail.com>: >> >>> >>> Theo Schlossnagle wrote: >>> >>>> >>>> I didn't look deeply at the postgres internals to see if there was a way >>>> to do double -> numeric and integer-types -> numeric without >>>> intermediary >>>> string format. Â If that sort of thing is easy to leverage, I'd be happy >>>> to >>>> share the code. >>>> >>>> >>> >>> I think your code could be valuable for postgres on the fact alone that >>> it >>> is almost twice as fast, and probably easy to integrate and unit test. We >>> make heavy use of the numeric data type, so I'm very interested! >>> >> >> I did some test and numeric->double is about 5% faster than >> numeric->string->double (on my PC) >> > > numeric_to_double_no_overflow() also uses string as intermediate format. > > Theo's conversions are the converse, from double to numeric, and do not use > string as intermediate format (if I understand it correct). (where > float8_numeric > http://doxygen.postgresql.org/backend_2utils_2adt_2numeric_8c.html#2de7f65c8de4b65dad441e77ea1bf402 > does) > aha - it is reason why time similar Pavel > regards > Yeb Havinga > > -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Theo Schlossnagle on 3 Mar 2010 09:52 I can't release all of it, but the functions to convert uint64_t, int64_t and double to numeric Datum are the meat and I can expose those... https://labs.omniti.com/pgsoltools/trunk/contrib/scratch/pg_type_to_numeric..c As I mentioned, the dscale on the double_to_numeric is imperfect resulting in things like: 1.23 turning into 1.2300 in the numeric returned. This are significantly faster (as expected) than the type -> string -> numeric conversions. On Mar 3, 2010, at 5:01 AM, Yeb Havinga wrote: > Theo Schlossnagle wrote: >> I didn't look deeply at the postgres internals to see if there was a way to do double -> numeric and integer-types -> numeric without intermediary string format. If that sort of thing is easy to leverage, I'd be happy to share the code. >> > I think your code could be valuable for postgres on the fact alone that it is almost twice as fast, and probably easy to integrate and unit test. We make heavy use of the numeric data type, so I'm very interested! > > regards > Yeb Havinga > > -- Theo Schlossnagle http://omniti.com/is/theo-schlossnagle -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Grzegorz Jaskiewicz on 3 Mar 2010 12:41 if (p1 > buf) ++ * --p1; else { ..... ++ * --p1; ??? does it even compile ? -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Grzegorz Jaskiewicz on 3 Mar 2010 15:37
On 3 Mar 2010, at 17:41, Grzegorz Jaskiewicz wrote: > if (p1 > buf) > ++ * --p1; > else { > > .... > > > ++ * --p1; ??? > > does it even compile ? Oh, I can see, that it is *(--p1)++ ,mea culpa. Which doesn't change the fact, that the code is rather messy imo. -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers |