pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ruben Rubio Rey <ruben@rentalia.com>
To: pgsql-performance@postgresql.org
Subject: Re: Array performance
Date: Fri, 24 Mar 2006 14:01:29 +0100
Message-ID: <4423EDA9.3090502@rentalia.com> (raw)
In-Reply-To: <20060324125245.GB90527@pervasive.com>
References: <200603170625.k2H6PJ926955@pillette.com>
	<1143112188.2810.27.camel@theo-laptop.int.coza.net.za>
	<20060323132448.GB4881@surnet.cl>
	<4423E90E.2090607@rentalia.com>
	<20060324125245.GB90527@pervasive.com>

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
>  
>





view thread (7+ messages)  latest in thread

Message-ID: <4423EDA9.3090502@rentalia.com>
Permalink:  ../4423EDA9.3090502@rentalia.com/
Also on:    postgresql.org/message-id/4423EDA9.3090502@rentalia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: ruben@rentalia.com
  Subject: Re: Array performance
  In-Reply-To: <4423EDA9.3090502@rentalia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox