X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 1CBA29DC99B for ; Mon, 2 Jan 2006 17:48:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50010-06 for ; Mon, 2 Jan 2006 17:48:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C54DC9DC991 for ; Mon, 2 Jan 2006 17:48:44 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k02Lmjb5012504; Mon, 2 Jan 2006 16:48:45 -0500 (EST) To: "Qingqing Zhou" cc: pgsql-hackers@postgresql.org Subject: Re: Stats collector performance improvement In-reply-to: References: <200601021840.k02Ieed21704@candle.pha.pa.us> <11924.1136233224@sss.pgh.pa.us> Comments: In-reply-to "Qingqing Zhou" message dated "Mon, 02 Jan 2006 16:03:20 -0500" Date: Mon, 02 Jan 2006 16:48:45 -0500 Message-ID: <12503.1136238525@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.061 required=5 tests=[AWL=0.061] X-Spam-Score: 0.061 X-Spam-Level: X-Archive-Number: 200601/78 X-Sequence-Number: 78182 "Qingqing Zhou" writes: > AFAICS if we can maintain the stats counts solid, then it may hurt > performance dramatically. Think if we maintain > pgstat_count_heap_insert()/pgstat_count_heap_delete() pretty well, then we > get a replacement of count(*). Not at all. For one thing, the stats don't attempt to maintain per-transaction state, so they don't have the MVCC issues of count(*). I'm not suggesting any fundamental changes in what is counted or when. The two compromises that were made in the original stats design to make it fast were (1) stats updates lag behind reality, and (2) some updates may be missed entirely. Now that we have a couple of years' field experience with the code, it seems that (1) is acceptable for real usage but (2) not so much. And it's not even clear that we are buying any performance gain from (2), considering that it's adding the overhead of passing the data through an extra process. regards, tom lane