Re: PLPERL Function very Slow

From: "codeWarrior" <gpatnude(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PLPERL Function very Slow
Date: 2006-08-30 18:15:08
Message-ID: ed4ke5$11u3$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

1 -- Drop your indexes on the table to be inserted into.
2 -- Execute a BEGIN transaction
3 -- Execute your inserts.
4 -- Execute a commit or rollback and END transaction
5 -- Rebuild / recreate your indexes

"Alex" <alex(at)meerkatsoft(dot)com> wrote in message
news:44F5A014(dot)3070409(at)meerkatsoft(dot)com(dot)(dot)(dot)
> Hi,
> i am having a problem with a plperl function i am trying to write.
> (using 8.1.4)
>
> the function does a select (ca 30,000 rows) using
>
> spi_query($query); while (my $row = spi_fetchrow($handle))
>
> and within the while loop inserts the record into a table using
> spi_exec_query($query);
>
> The initial select is pretty fast and first inserts very fast, but after
> a few thousand inserts the inserts start to slow down until it crawls.
> Writing the same in a normal perl script takes less than 90 seconds
> while the function is taking 10 minutes.
>
> My guess is that it is all memory related and was wondering if there is
> a memory leak (as I read in some mails) or if there is a better way to
> do what I want.
>
> Also is there a way to commit transactions within a stored procedure /
> function? I noticed that if I do a delete and insert within the same
> function that the deletes are not committed until the function returns.
>
> Thanks for any advice.
>
> Alex
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Maguire 2006-08-30 18:15:19 Dblink and connections to MySQL?
Previous Message Joshua D. Drake 2006-08-30 18:14:16 Re: plz unsubscribe me