Re: insert performance riddle

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: insert performance riddle
Date: 2005-08-11 00:03:34
Message-ID: 20050811000333.GA55773@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 10, 2005 at 05:02:46PM -0600, Ed L. wrote:
> I have two identical servers giving abysmal INSERT performance in
> pgsql 7.3.4, 7.4.8, and 8.1devel under no load or I/O contention
> at all (no dumps, no vacuums, no apps, etc). Any suggested
> investigations appreciated...
>
> Metric: I'm measuring average insert speed on the following
> table with the following psuedo-loop via DBI 1.48 and DBD::Pg
> 1.43 (older versions of DBD::Pg/DBI are slow, too):
>
> create table foo (id serial, msg varchar);
> for i in 1..1000 do
> insert into foo (msg, "this is a test message");
>
> Results: The slow servers are doing 6...count'em, SIX...that's
> right, I said S-I-X inserts per second (QPS) on average.

Have you done any tests that eliminate the client code and client-server
communcation? Something like the following:

CREATE TABLE foo (id serial, msg varchar);

CREATE FUNCTION insert_foo(integer) RETURNS void AS '
DECLARE
i integer;
BEGIN
FOR i IN 1 .. $1 LOOP
INSERT INTO foo (msg) VALUES (''this is a test message'');
END LOOP;

RETURN;
END;
' LANGUAGE plpgsql VOLATILE STRICT;

EXPLAIN ANALYZE SELECT insert_foo(1000);

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2005-08-11 00:54:33 Re: What's up with EnterpriseDB?
Previous Message Ed L. 2005-08-10 23:02:46 insert performance riddle