X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87F848B9D10 for ; Fri, 4 Feb 2005 20:09:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44243-02 for ; Fri, 4 Feb 2005 20:08:56 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) by svr1.postgresql.org (Postfix) with ESMTP id 6FBFE8B9B2B for ; Fri, 4 Feb 2005 20:08:56 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 40so391199wri for ; Fri, 04 Feb 2005 12:08:56 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=J5chiblqovliYEfJ0NjwrEbxr0VhKsvhMwhZY7MSdaa1hbAcjbznuurScxGjzkbvlJDYhl2JMfOpmzJY5JquD78mF+go8fgbisvKX16VtZgydbOJrMSiKVygFJQUmuwbrNlTVQNpkmdgz8un7l6hwvV7yFX9ejG+qsx4aiSekCw= Received: by 10.54.59.37 with SMTP id h37mr188618wra; Fri, 04 Feb 2005 12:08:56 -0800 (PST) Received: by 10.54.20.47 with HTTP; Fri, 4 Feb 2005 12:08:56 -0800 (PST) Message-ID: <1dc7f0e305020412085bef5611@mail.gmail.com> Date: Fri, 4 Feb 2005 15:08:56 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: Merlin Moncure Subject: Re: Flattening a kind of 'dynamic' table Cc: Joe Conway , PERFORM In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7611@Herge.rcsinc.local> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <6EE64EF3AB31D5448D0007DD34EEB3412A7611@Herge.rcsinc.local> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200502/77 X-Sequence-Number: 10406 On Fri, 4 Feb 2005 12:48:43 -0500, Merlin Moncure 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