Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id F034A9FB290 for ; Tue, 6 Feb 2007 17:39:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 55744-07 for ; Tue, 6 Feb 2007 17:39:23 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 816D39FB251 for ; Tue, 6 Feb 2007 17:39:25 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 59A2430B4A; Tue, 6 Feb 2007 22:39:24 +0100 (MET) From: "Karen Hill" X-Newsgroups: pgsql.performance Subject: Re: How long should it take to insert 200,000 records? Date: 6 Feb 2007 13:39:16 -0800 Organization: http://groups.google.com Lines: 55 Message-ID: <1170797956.583767.246670@p10g2000cwp.googlegroups.com> References: <1170722158.973141.208230@j27g2000cwj.googlegroups.com> <29906.1170740015@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com In-Reply-To: <29906.1170740015@sss.pgh.pa.us> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p10g2000cwp.googlegroups.com; posting-host=209.102.127.150; posting-account=UskOZg0AAABeGutYp_rJHX2WGbDZ3a_l To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.696 tagged_above=0 required=5 tests=AWL, BAYES_00, FORGED_YAHOO_RCVD, FROM_HAS_ULINE_NUMS X-Spam-Level: X-Archive-Number: 200702/78 X-Sequence-Number: 23132 On Feb 5, 9:33 pm, t...@sss.pgh.pa.us (Tom Lane) wrote: > "Karen Hill" writes: > > I have a pl/pgsql function that is inserting 200,000 records for > > testing purposes. What is the expected time frame for this operation > > on a pc with 1/2 a gig of ram and a 7200 RPM disk? > > I think you have omitted a bunch of relevant facts. Bare INSERT is > reasonably quick: > > regression=# create table foo (f1 int); > CREATE TABLE > regression=# \timing > Timing is on. > regression=# insert into foo select x from generate_series(1,200000) x; > INSERT 0 200000 > Time: 5158.564 ms > regression=# > > (this on a not-very-fast machine) but if you weigh it down with a ton > of index updates, foreign key checks, etc, it could get slow ... > also you haven't mentioned what else that plpgsql function is doing. > 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;