X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64D96475C3D for ; Wed, 16 Apr 2003 11:48:52 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 9118F475C15 for ; Wed, 16 Apr 2003 11:48:51 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2967362; Wed, 16 Apr 2003 08:48:49 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "scott.marlowe" , linweidong Subject: Re: for help! Date: Wed, 16 Apr 2003 08:48:36 -0700 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200304160848.36431.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/142 X-Sequence-Number: 1648 Scott, > Well, you can always use the trick of putting an on insert / delete > trigger on the table that maintains a single row table with the current > count. That way, whenever a row is added or removed, the count is > updated. this will slow down inserts and deletes a little, but TANSTAAFL. BTW, I tested this for a client. I found the performance penalty on inser= ts=20 and updates to be: -- For a single stream of intermittent updates from a single connection on an adequately powered server with moderate disk support (IDE Linux RA= ID) (100 inserts/updates per minute, with VACUUM every 5 minutes) PL/pgSQL Trigger: 20% penalty C Trigger: 9-11% penalty -- For 5 streams of inserts and updates at high volume on an overloaded server with moderate disk support (dual fast SCSI disks) (1000 inserts/updates per minute, vacuum every 5 minutes) PL/pgSQL Trigger: 65% penalty C Trigger: 40% penalty Please note that the effective performance penalty on inserts and updates w= as=20 dramatically higher for large batches of updates than for small ones. --=20 Josh Berkus Aglio Database Solutions San Francisco