Re: [PATCH] Custom code int(32|64) => text conversions out of performance reasons
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <gsstark@mit.edu>
Cc: Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>, pgsql-hackers@postgresql.org
Date: 2010-11-20T20:21:20Z
Lists: pgsql-hackers
Greg Stark <gsstark@mit.edu> writes: > On Sat, Nov 20, 2010 at 6:31 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Robert Haas <robertmhaas@gmail.com> writes: >>> I had given some thought to whether it might make sense to try to >>> figure out how long the string will be before we actually start >>> generating it, so that we can just start in the exactly right space >>> and have to clean up afterward. But the obvious implementation seems >>> like it could be more expensive than just doing the copy. >> Yeah. You certainly don't want to do the division sequence twice, >> and a log() call wouldn't be cheap either, and there don't seem to >> be many other alternatives. > There are bittwiddling hacks for computing log based 2. I'm not sure > it's worth worrying about to this degree though. I think converting log2 to log10 *exactly* would end up being not so cheap, anyhow. regards, tom lane