X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C348B9FA380 for ; Tue, 23 May 2006 17:03:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 38639-01 for ; Tue, 23 May 2006 17:02:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 953029FA279 for ; Tue, 23 May 2006 17:02:51 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id A6A8D5643D; Tue, 23 May 2006 15:02:49 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Tue, 23 May 2006 15:02:48 -0500 Date: Tue, 23 May 2006 15:02:48 -0500 From: "Jim C. Nasby" To: Tom Lane , Dan Gorman , mischa@ca.sophos.com, pgsql-performance@postgresql.org Subject: Re: Selects query stats? Message-ID: <20060523200248.GY64371@pervasive.com> References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> <4473512E.7020805@ca.sophos.com> <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> <4473553C.1010804@ca.sophos.com> <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> <20060523184100.GW64371@pervasive.com> <17713.1148411593@sss.pgh.pa.us> <20060523195001.GH28863@surnet.cl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060523195001.GH28863@surnet.cl> X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060523:tgl@sss.pgh.pa.us::GWBwX+rALPhgo/M+:00000000000000000000 0000000000000000000000003QLe X-Hashcash: 1:20:060523:dgorman@hi5.com::SyLhhhs9zBLUCbjp:003+yK X-Hashcash: 1:20:060523:mischa@ca.sophos.com::+fjiVxaT+vf3bcTH:00000000000000000 00000000000000000000000011g4 X-Hashcash: 1:20:060523:pgsql-performance@postgresql.org::pS5kLUj449itA25f:00000 0000000000000000000000004EoU X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/440 X-Sequence-Number: 19227 On Tue, May 23, 2006 at 03:50:01PM -0400, Alvaro Herrera wrote: > Tom Lane wrote: > > > Counting individual statements would add overhead (which the OP already > > declared unacceptable) and there are some definitional issues too, like > > whether to count statements executed within functions. > > Yeah, the problem seems underspecified. How do you count statements > added or removed by rewrite rules? Statements executed to answer RI > queries? Do you count the statements issued by clients as part of the > startup sequence? The hypothetical "reset session" of a connection pool > handler? How do you count 2PC -- when they are executed, or when they > are committed? What happens to statements in transactions that are > rolled back? What happens to a statement that is executed partially > because it failed partway (e.g. because of division by zero)? > > > OTOH ISTM it would be easy to modify Postgres so as to count statements > in the stat collector, by turning pgstat_report_activity into a routine > that sent a count (presumably always 1) instead of the query string, and > then just add the count to a counter on receiving. Yeah, I doubt any other database gets mired neck-deep in exact details of statment execution counts; a simple count of queries executed via a client connection would be a great start. I often run into situations where people are having a performance issue because they're building web pages that make 50 queries to the database. Being able to identify that and determine how many were selects vs. DML would be useful. Bonus points if there are seperate counters for statements from functions. -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461