Re: Flattening a kind of 'dynamic' table

From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "Joe Conway" <mail(at)joeconway(dot)com>
Cc: "PERFORM" <pgsql-performance(at)postgresql(dot)org>, "Alexandre Leclerc" <alexandre(dot)leclerc(at)gmail(dot)com>
Subject: Re: Flattening a kind of 'dynamic' table
Date: 2005-02-04 17:48:43
Message-ID: 6EE64EF3AB31D5448D0007DD34EEB3412A7611@Herge.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> Alexandre Leclerc wrote:
> Sorry for jumping in on this thread so late -- I haven't been able to
> select * from crosstab(
> 'select product_id, department_id, req_time
> from product_department_time order by 1',
> 'select ''A'' union all select ''C'' union all select ''D'''
> ) as (product_id int, a int, c int, d int);

I forgot you could do this...This would certainly be easier than parsing
array values returned from array_accum. It will probably be faster as
well...but with the array approach the query would not have to be
modified each time a new department was added. That said, a crosstab
based query could be built easily enough from a department query on the
client and then you have the best of both worlds.

Merlin

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Sanketh Indarapu 2005-02-04 19:29:36 Postgres odbc performance on windows
Previous Message Bruce Momjian 2005-02-04 04:39:44 Re: Planner really hates nested loops