Re: Strange plpgsql performance -- arithmetic, numeric() - Mailing list pgsql-general

From Karl O. Pinc
Subject Re: Strange plpgsql performance -- arithmetic, numeric()
Date
Msg-id 1112625849l.21019l.1l@mofo
Whole thread Raw
In response to Re: Strange plpgsql performance -- arithmetic, numeric() type, arrays  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 04/03/2005 08:04:27 PM, Tom Lane wrote:
> "Karl O. Pinc" <kop@meme.com> writes:
> > Incrementing the loop counter by a factor of 10, from 1000 to 10000
> > makes the process take more than 100 times longer.  (I only saw
> > this happen when I happened upon using a numeric() datatype
> > and then dividing i/100 to avoid overflow.  It does not happen
> > without the array and working with other, much larger, arrays
> > of other data types you see no slowdown.)
>
> It's the array access, not the arithmetic, that's getting you.
> Since numeric is not a fixed-width datatype, accessing the N'th
> element of the array requires O(N) time to find that element.

Makes sense.  Thanks.  (Makes me think that these sorts of arrays
should be implimented with an extra level of indirection,
an array of pointers to the varying data, which may not be the
best way to represent arrays on disk because storage requirements
go up and disk is slow....  Anyhow, I leave it
to the coders.)

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein



pgsql-general by date:

Previous
From: Ragnar Hafstað
Date:
Subject: Re: Time
Next
From: John Burger
Date:
Subject: Re: Crazy Multiplication Issue