Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5DF719FA44C for ; Fri, 21 Sep 2007 13:35:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 57891-09 for ; Fri, 21 Sep 2007 13:35:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by postgresql.org (Postfix) with ESMTP id 1F7C49F9D9C for ; Fri, 21 Sep 2007 13:35:31 -0300 (ADT) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Fri, 21 Sep 2007 11:35:30 -0500 Message-Id: <46F3AC73.EE98.0025.0@wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.2 Date: Fri, 21 Sep 2007 11:35:15 -0500 From: "Kevin Grittner" To: "Kamen Stanev" , Subject: Re: query io stats and finding a slow query References: In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/370 X-Sequence-Number: 26915 >>> On Thu, Sep 20, 2007 at 4:36 PM, in message , "Kamen = Stanev" wrote:=20 >=20 > Is there a way to find which query is doing large io operations and/or = which > is using cached data and which is reading from disk. =20 A big part of your cache is normally in the OS, which makes that tough. =20 > please share your experience on how do you decide which > queries to optimize and how to reorganize your database? =20 We base this on two things -- query metrics from our application framework and user complaints about performance. > Is there any tools that you use to profile your database. =20 Many people set log_min_duration_statement to get a look at long-running queries. =20 When you identify a problem query, running it with EXPLAIN ANALYZE in = front will show you the plan with estimated versus actual counts, costs, and = time. This does actually execute the query (unlike EXPLAIN without ANALYZE). =20 -Kevin =20