Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 12633632726 for ; Wed, 2 Jun 2010 07:10:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 41177-01 for ; Wed, 2 Jun 2010 10:10:29 +0000 (UTC) X-Greylist: delayed 00:06:38.55796 by SQLgrey-1.7.6 Received: from 27.mail-out.ovh.net (27.mail-out.ovh.net [91.121.30.210]) by mail.postgresql.org (Postfix) with SMTP id 2547F6325E4 for ; Wed, 2 Jun 2010 07:10:28 -0300 (ADT) Received: (qmail 12195 invoked by uid 503); 2 Jun 2010 10:07:12 -0000 Received: from b6.ovh.net (HELO mail438.ha.ovh.net) (213.186.33.56) by 27.mail-out.ovh.net with SMTP; 2 Jun 2010 10:07:12 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 2 Jun 2010 12:03:47 +0200 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO immo.peufeu.com) (lists%peufeu.com@88.161.102.87) by ns0.ovh.net with SMTP; 2 Jun 2010 12:03:46 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Joachim Worringen" , pgsql-performance@postgresql.org Subject: Re: performance of temporary vs. regular tables References: <4BFB837C.6010005@iathh.de> <4BFB91A8.20805@iathh.de> <201005251241.59605.andres@anarazel.de> <4BFD4643.9010901@iathh.de> <4BFFA32D.8010009@iathh.de> Date: Wed, 02 Jun 2010 12:03:42 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: <4BFFA32D.8010009@iathh.de> User-Agent: Opera Mail/10.10 (Linux) X-Ovh-Tracer-Id: 3207125885418604266 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.8 tagged_above=-10 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/18 X-Sequence-Number: 38874 > As promised, I did a tiny benchmark - basically, 8 empty tables are > filled with 100k rows each within 8 transactions (somewhat typically for > my application). The test machine has 4 cores, 64G RAM and RAID1 10k > drives for data. > > # INSERTs into a TEMPORARY table: > [joachim@testsrv scaling]$ time pb query -d scaling_qry_1.xml > > real 3m18.242s > user 1m59.074s > sys 1m51.001s > > # INSERTs into a standard table: > [joachim@testsrv scaling]$ time pb query -d scaling_qry_1.xml > > real 3m35.090s > user 2m5.295s > sys 2m2.307s > > Thus, there is a slight hit of about 10% (which may even be within > meausrement variations) - your milage will vary. Usually WAL causes a much larger performance hit than this. Since the following command : CREATE TABLE tmp AS SELECT n FROM generate_series(1,1000000) AS n which inserts 1M rows takes 1.6 seconds on my desktop, your 800k rows INSERT taking more than 3 minutes is a bit suspicious unless : - you got huge fields that need TOASTing ; in this case TOAST compression will eat a lot of CPU and you're benchmarking TOAST, not the rest of the system - you got some non-indexed foreign key - some other reason ?