X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C536A9DCBA3 for ; Thu, 16 Feb 2006 17:14:01 -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 95143-07 for ; Thu, 16 Feb 2006 17:14:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from r1.mycybernet.net (r1.mycybernet.net [209.5.206.8]) by postgresql.org (Postfix) with ESMTP id 822919DCB28 for ; Thu, 16 Feb 2006 17:13:59 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227]:34089 helo=phlogiston.dydns.org) by r1.mycybernet.net with esmtp (Exim 4.50 (FreeBSD)) id 1F9qRs-000HsP-Nf; Thu, 16 Feb 2006 16:14:00 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 108EA4046; Thu, 16 Feb 2006 16:14:00 -0500 (EST) Date: Thu, 16 Feb 2006 16:14:00 -0500 From: Andrew Sullivan To: "Kashmira Patel (kupatel)" Cc: Andrew Sullivan , pgsql-sql@postgresql.org Subject: Re: Using EXPLAIN-ANALYZE Message-ID: <20060216211400.GB9872@phlogiston.dyndns.org> References: <18AE59788A3FC640A367E5652E664D8001928860@xmb-sjc-237.amer.cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18AE59788A3FC640A367E5652E664D8001928860@xmb-sjc-237.amer.cisco.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.097 required=5 tests=[AWL=0.097] X-Spam-Score: 0.097 X-Spam-Level: X-Archive-Number: 200602/214 X-Sequence-Number: 24224 On Thu, Feb 16, 2006 at 01:08:40PM -0800, Kashmira Patel (kupatel) wrote: > So I would have to put in lots of rows of data in the table before using > the explain command? Well, no, but you won't get useful information without it. PostgreSQL has a cost-based optimizer. The query plan is affected by the nature of your data. That's what the ANALYZE command (on its own, or with VACUUM) is for. A > > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: Thursday, February 16, 2006 12:39 PM > To: pgsql-sql@postgresql.org > Subject: Re: [SQL] Using EXPLAIN-ANALYZE > > On Thu, Feb 16, 2006 at 12:07:10PM -0800, Kashmira Patel (kupatel) > wrote: > > Hi all, > > I am pretty new to using Postrgres, and have been looking at the > > messages in this forum for a while. I have noticed that the use of > > EXPLAIN-ANALYZE is recommended quite a lot. I read the Postgres docs, > > but am not quite sure I understand how this works. Is there some > > tutorial or any other documentation how this can be used? > > Well, here's the short version: > > EXPLAIN [query] tells you what the planner _thinks_ it should do. > > EXPLAIN ANALYZE [query] tells you what the planner thinks it should do, > and also executes the query and reports back how long every step took, > how many rows were returned, &c. (For this reason, you want to wrap it > in BEGIN;...;ROLLBACK; if it changes data.) > > For more, see the EXPLAIN EXPLAINED tutorial on techdocs.postgresql.org > ( _Explain_Public.sxi>) > > A > > -- > Andrew Sullivan | ajs@crankycanuck.ca > In the future this spectacle of the middle classes shocking the avant- > garde will probably become the textbook definition of Postmodernism. > --Brad Holland > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Andrew Sullivan | ajs@crankycanuck.ca The fact that technology doesn't work is no bar to success in the marketplace. --Philip Greenspun