Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TWQha-0003XJ-S9 for pgsql-performance@postgresql.org; Thu, 08 Nov 2012 11:55:18 +0000 Received: from mxout2.ac.twooit.com ([2a03:2900:1:a::b]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TWQhU-0004Cf-OF for pgsql-performance@postgresql.org; Thu, 08 Nov 2012 11:55:17 +0000 Received: from mxbox2.ac.twooit.com (unknown [192.168.10.252]) by mxout2.ac.twooit.com (Postfix) with ESMTP id 5E7CB5C26B for ; Thu, 8 Nov 2012 11:55:10 +0000 (UTC) Received: from mailerdienst.de (wwwmaster.ac.twooit.com [95.129.51.47]) by mxbox2.ac.twooit.com (Postfix) with ESMTPA id 53A898464F; Thu, 8 Nov 2012 12:55:10 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 08 Nov 2012 12:55:12 +0100 From: Oliver Seidel To: Subject: parallel query evaluation Reply-To: Mail-Reply-To: Message-ID: <214a89820818a3da44bcadb4ab829c14@os10000.net> X-Sender: postgresql@os10000.net User-Agent: Webmail/0.6 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201211/125 X-Sequence-Number: 48491 Hi, I have create table x ( att bigint, val bigint, hash varchar(30) ); with 693million rows. The query create table y as select att, val, count(*) as cnt from x group by att, val; ran for more than 2000 minutes and used 14g memory on an 8g physical RAM machine -- eventually I stopped it. Doing create table y ( att bigint, val bigint, cnt int ); and something a bit like: for i in `seq 0 255` | xargs -n 1 -P 6 psql -c "insert into y select att, val, count(*) from x where att%256=$1 group by att, val" test runs 6 out of 256 in 10 minutes -- meaning the whole problem can be done in just under 3 hours. Question 1: do you see any reason why the second method would yield a different result from the first method? Question 2: is that method generalisabl so that it could be included in the base system without manual shell glue? Thanks, Oliver