Re: How to determine cause of performance problem?

From: Michael Stone <mstone+postgres(at)mathom(dot)us>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: How to determine cause of performance problem?
Date: 2005-09-23 15:31:18
Message-ID: 20050923153118.GB14918@mathom.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Sep 23, 2005 at 03:49:25PM +0200, Joost Kraaijeveld wrote:
>On Fri, 2005-09-23 at 07:05 -0400, Michael Stone wrote:
>> Ok, that's great, but you didn't respond to the suggestion of using COPY
>> INTO instead of INSERT.
>Part of the code I left out are some data conversions (e.g. from
>path-to-file to blob, from text to date (not castable because of the
>homebrew original format)). I don't believe that I can do these in a SQL
>statement, can I (my knowledge of SQL as a langage is not that good)? .
>However I will investigate if I can do the conversion in two steps and
>check if it is faster.

I'm not sure what you're trying to say.

You're currently putting rows into the table by calling "INSERT INTO"
for each row. The sample code you send could be rewritten to use "COPY
INTO" instead. For bulk inserts like you're doing, the copy approach
will be a lot faster. Instead of inserting one row, waiting for a
reply, and inserting the next row, you just cram data down a pipe to the
server.

See:
http://www.postgresql.org/docs/8.0/interactive/sql-copy.html
http://www.faqs.org/docs/ppbook/x5504.htm

Mike Stone

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2005-09-23 15:31:28 Re: Releasing memory during External sorting?
Previous Message K C Lau 2005-09-23 15:08:20 Re: SELECT LIMIT 1 VIEW Performance Issue