Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B73CB9FB2D7 for ; Tue, 6 Feb 2007 22:41:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 09951-02 for ; Tue, 6 Feb 2007 22:41:45 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtp4.clear.net.nz (smtp4.clear.net.nz [203.97.37.64]) by postgresql.org (Postfix) with ESMTP id 335BF9FB2C7 for ; Tue, 6 Feb 2007 22:41:45 -0400 (AST) Received: from [192.168.1.11] (121-72-72-1.dsl.telstraclear.net [121.72.72.1]) by smtp4.clear.net.nz (CLEAR Net Mail) with ESMTP id <0JD20032RNHIKG10@smtp4.clear.net.nz> for pgsql-performance@postgresql.org; Wed, 07 Feb 2007 15:41:42 +1300 (NZDT) Date: Wed, 07 Feb 2007 15:41:34 +1300 From: Mark Kirkwood Subject: Re: How long should it take to insert 200,000 records? In-reply-to: <1170797956.583767.246670@p10g2000cwp.googlegroups.com> To: Karen Hill Cc: pgsql-performance@postgresql.org Message-id: <45C93C5E.4030706@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <1170722158.973141.208230@j27g2000cwj.googlegroups.com> <29906.1170740015@sss.pgh.pa.us> <1170797956.583767.246670@p10g2000cwp.googlegroups.com> User-Agent: Thunderbird 1.5.0.9 (X11/20061227) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/80 X-Sequence-Number: 23134 Karen Hill wrote: > > The postgres version is 8.2.1 on Windows. The pl/pgsql function is > inserting to an updatable view (basically two tables). > > CREATE TABLE foo1 > ( > > > ) ; > > CREATE TABLE foo2 > ( > > ); > > CREATE VIEW viewfoo AS > ( > > ); > CREATE RULE ruleFoo AS ON INSERT TO viewfoo DO INSTEAD > ( > > ); > > CREATE OR REPLACE FUNCTION functionFoo() RETURNS VOID AS $$ > BEGIN > FOR i in 1..200000 LOOP > INSERT INTO viewfoo (x) VALUES (x); > END LOOP; > END; > $$ LANGUAGE plpgsql; > Sorry - but we probably need *still* more detail! - the definition of viewfoo is likely to be critical. For instance a simplified variant of your setup does 200000 inserts in 5s on my PIII tualatin machine: CREATE TABLE foo1 (x INTEGER); CREATE VIEW viewfoo AS SELECT * FROM foo1; CREATE RULE ruleFoo AS ON INSERT TO viewfoo DO INSTEAD ( INSERT INTO foo1 VALUES (new.x); ) CREATE OR REPLACE FUNCTION functionFoo() RETURNS VOID AS $$ BEGIN FOR i in 1..200000 LOOP INSERT INTO viewfoo (x) VALUES (i); END LOOP; END; $$ LANGUAGE plpgsql; postgres=# \timing postgres=# SELECT functionFoo() ; functionfoo ------------- (1 row) Time: 4659.477 ms postgres=# SELECT count(*) FROM viewfoo; count -------- 200000 (1 row) Cheers Mark