Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 13CA0475775 for ; Fri, 23 Aug 2002 21:08:23 -0400 (EDT) Received: from smtp.comcast.net (smtp.comcast.net [24.153.64.2]) by postgresql.org (Postfix) with ESMTP id 90642475153 for ; Fri, 23 Aug 2002 21:08:22 -0400 (EDT) Received: from stllnx1.stlassoc.com (pcp01376419pcs.selrsv01.pa.comcast.net [68.80.68.209]) by mtaout03.icomcast.net (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 13 2002)) with ESMTP id <0H1B0099EPU2YY@mtaout03.icomcast.net> for pgsql-admin@postgresql.org; Fri, 23 Aug 2002 21:08:26 -0400 (EDT) Received: from tlowery by stllnx1.stlassoc.com with local (MasqMail 0.1.8c) id 17iPPd-3BX-00 for pgsql-admin@postgresql.org; Fri, 23 Aug 2002 21:08:25 -0400 Date: Fri, 23 Aug 2002 21:08:25 -0400 From: "Thomas A. Lowery" Subject: Re: Performance Problems In-reply-to: <"from alexp"@meta-bit.com> To: pgsql-admin@postgresql.org Mail-Followup-To: pgsql-admin@postgresql.org Message-id: <20020823210825.A12098@stllnx1.stlassoc.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: Linux/2.4.18-5smp (i586) X-Uptime: 8:54pm up 4 days, 21:05, 5 users, load average: 0.47, 0.36, 0.20 References: <3D663946.4050008@meta-bit.com> <19614.1030110585@sss.pgh.pa.us> <3D6644E2.2030707@meta-bit.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/342 X-Sequence-Number: 5456 Alex, You're able to alter the autocommit value during processing: $dbh->{AutoCommit} = 0; $dbh->do( qq{insert into yucky values ('A')} ); $dbh->commit; $dbh->{AutoCommit} = 1; $dbh->do( qq{truncate table yucky} ); $dbh->{AutoCommit} = 0; $dbh->do( qq{insert into yucky values ('A')} ); $dbh->commit; Do you need the use of a temp database table? If so have you looked at using a memory resident table (DBD::AnyData)? Another thing I've found that helps is to cache reference or lookup data. Memoize is an easy way to cache. This only works for data that doesn't change between queries select x from y where z = 1 always returns 'F' ... Tom On Fri, Aug 23, 2002 at 11:21:22PM +0900, Alex Paulusberger wrote: > Tom, > thanks. I do use DELETE FROM since truncate is not an option in > trnansaction blocks > and within DBI , autocommit has to be turned off when connecting to the DB. > > But maybe you are right, and the overhead not being able to truncate > tables is bigger than > not using transaction blocks. > > Regards > Alex > > Tom Lane wrote: > > >Another thought... > > > >Alex Paulusberger writes: > > > >>The whole process loops 4,500 times. > >>For every loop > >>- a temp table is cleared > >> > > > >How exactly are you clearing the temp table? DELETE FROM isn't a good > >plan because you'll still have dead tuples in there. You could do a > >DELETE FROM and then VACUUM, but I'd suggest TRUNCATE instead.