Re: Array performance - Mailing list pgsql-performance

From Ruben Rubio Rey
Subject Re: Array performance
Date
Msg-id 4423EDA9.3090502@rentalia.com
Whole thread Raw
In response to Re: Array performance  ("Jim C. Nasby" <jnasby@pervasive.com>)
Responses Re: Array performance  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-performance
Jim C. Nasby wrote:

>On Fri, Mar 24, 2006 at 01:41:50PM +0100, Ruben Rubio Rey wrote:
>
>
>>Hi,
>>
>>I have a select like
>>
>>SELECT (array[20]+array[21]+ ... +array[50]+array[51]) as total
>>FROM table
>>WHERE
>>(array[20]+array[21]+ ... +array[50]+array[51])<5000
>>
>>
>
>http://www.varlena.com/GeneralBits/109.php might provide some useful
>insights. I also recall seeing something about sum operators for arrays,
>but I can't recall where.
>
>
I ll check it out, seems to be very useful
Is faster create a function to sum the array?

>
>
>>AND array[20]<>0
>>AND array[21]<>0
>>...
>>AND array[50]<>0
>>AND array[51])<>0
>>
>>
>
>Uhm... please don't tell me that you're using 0 in place of NULL...
>
>
mmm ... i have read in postgres documentation that null values on arrays
are not supported ...

>You might be able to greatly simplify that by use of ANY; you'd need to
>ditch elements 1-19 though:
>
>... WHERE NOT ANY(array) = 0
>
>
Yep this is much better.

>See http://www.postgresql.org/docs/8.1/interactive/arrays.html
>
>



pgsql-performance by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: WAL logging of SELECT ... INTO command
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Array performance