From: Alexandre Leclerc <alexandre.leclerc@gmail.com>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: Joe Conway <mail@joeconway.com>
Cc: PERFORM <pgsql-performance@postgresql.org>
Subject: Re: Flattening a kind of 'dynamic' table
Date: Fri, 4 Feb 2005 15:08:56 -0500
Message-ID: <1dc7f0e305020412085bef5611@mail.gmail.com> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7611@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3412A7611@Herge.rcsinc.local>
On Fri, 4 Feb 2005 12:48:43 -0500, Merlin Moncure
<merlin.moncure@rcsonline.com> wrote:
> > 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.
Hello Merlin,
Well, I'm glad because with all this i've learn a lot of new things.
Finally, the crosstab solution is very fast and is simple for me to
use. I get my super-bug-jumbo-dbkiller-query run in about 210ms
(seeking many tables and so). I had a score of 2480ms before. (This is
a much more complex query; the cross table thing had to be included in
this one.) This is much better! :)
In all, thanks for your help. Regards.
--
Alexandre Leclerc
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: alexandre.leclerc@gmail.com, merlin.moncure@rcsonline.com, mail@joeconway.com
Subject: Re: Flattening a kind of 'dynamic' table
In-Reply-To: <1dc7f0e305020412085bef5611@mail.gmail.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