From: Steve Eckmann <eckmann@computer.org>
To: Kelly Burkhart <kelly@kkcsm.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: improving write performance for logging application
Date: Wed, 04 Jan 2006 17:19:08 -0700
Message-ID: <43BC65FC.3000903@computer.org> (raw)
In-Reply-To: <fa1e4ce70601040740t7f20ac13w9fddc80c10921c6@mail.gmail.com>
References: <43BB0C5C.8020207@computer.org>
<20060104000603.GA29469@uio.no>
<43BBD6E2.6080300@computer.org>
<fa1e4ce70601040740t7f20ac13w9fddc80c10921c6@mail.gmail.com>
Kelly Burkhart wrote:
> On 1/4/06, Steve Eckmann <eckmann@computer.org
> <mailto:eckmann@computer.org>> wrote:
>
> Thanks, Steinar. I don't think we would really run with fsync off,
> but I need to document the performance tradeoffs. You're right
> that my explanation was confusing; probably because I'm confused
> about how to use COPY! I could batch multiple INSERTS using COPY
> statements, I just don't see how to do it without adding another
> process to read from STDIN, since the application that is
> currently the database client is constructing rows on the fly. I
> would need to get those rows into some process's STDIN stream or
> into a server-side file before COPY could be used, right?
>
>
> Steve,
>
> You can use copy without resorting to another process. See the libpq
> documentation for 'Functions Associated with the copy Command". We do
> something like this:
>
> char *mbuf;
>
> // allocate space and fill mbuf with appropriately formatted data somehow
>
> PQexec( conn, "begin" );
> PQexec( conn, "copy mytable from stdin" );
> PQputCopyData( conn, mbuf, strlen(mbuf) );
> PQputCopyEnd( conn, NULL );
> PQexec( conn, "commit" );
>
> -K
Thanks for the concrete example, Kelly. I had read the relevant libpq
doc but didn't put the pieces together.
Regards, Steve
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: eckmann@computer.org, kelly@kkcsm.net
Subject: Re: improving write performance for logging application
In-Reply-To: <43BC65FC.3000903@computer.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox