Skip site navigation (1) Skip section navigation (2)

Re: Key/Value reference table generation: INSERT/UPDATE performance

From: valgog <valgog(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Key/Value reference table generation: INSERT/UPDATE performance
Date: 2007-05-22 10:35:29
Message-ID: 1179830129.622698.240380@x35g2000prf.googlegroups.com (view raw or flat)
Thread:
Lists: pgsql-performance
On May 22, 12:14 pm, l(dot)(dot)(dot)(at)peufeu(dot)com (PFC) wrote:
> On Tue, 22 May 2007 10:23:03 +0200, valgog <val(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> > I found several post about INSERT/UPDATE performance in this group,
> > but actually it was not really what I am searching an answer for...
>
> > I have a simple reference table WORD_COUNTS that contains the count of
> > words that appear in a word array storage in another table.
>
>         Mmm.
>
>         If I were you, I would :
>
>         - Create a procedure that flattens all the arrays and returns all the  
> words :
>
> PROCEDURE flatten_arrays RETURNS SETOF TEXT
> FOR word_array IN SELECT word_array FROM your_table LOOP
>         FOR i IN 1...array_upper( word_array ) LOOP
>                 RETURN NEXT tolower( word_array[ i ] )
>
> So, SELECT * FROM flatten_arrays() returns all the words in all the arrays.
> To get the counts quickly I'd do this :
>
> SELECT word, count(*) FROM flatten_arrays() AS word GROUP BY word
>
> You can then populate your counts table very easily and quickly, since  
> it's just a seq scan and hash aggregate. One second for 10.000 rows would  
> be slow.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq

good idea indeed! will try this approach.


In response to

pgsql-performance by date

Next:From: valgogDate: 2007-05-22 10:38:06
Subject: Re: Key/Value reference table generation: INSERT/UPDATE performance
Previous:From: PFCDate: 2007-05-22 10:14:48
Subject: Re: Key/Value reference table generation: INSERT/UPDATE performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group